LfrlAnvil.Mapping
0.1.0
See the version list below for details.
dotnet add package LfrlAnvil.Mapping --version 0.1.0
NuGet\Install-Package LfrlAnvil.Mapping -Version 0.1.0
<PackageReference Include="LfrlAnvil.Mapping" Version="0.1.0" />
<PackageVersion Include="LfrlAnvil.Mapping" Version="0.1.0" />
<PackageReference Include="LfrlAnvil.Mapping" />
paket add LfrlAnvil.Mapping --version 0.1.0
#r "nuget: LfrlAnvil.Mapping, 0.1.0"
#:package LfrlAnvil.Mapping@0.1.0
#addin nuget:?package=LfrlAnvil.Mapping&version=0.1.0
#tool nuget:?package=LfrlAnvil.Mapping&version=0.1.0
(root)
LfrlAnvil.Mapping
This project contains an object mapper, as well as a builder of such a mapper.
Examples
Following is an example of an implementation of a class that defines object mappings:
public class MyTypeMappingConfiguration : TypeMappingConfiguration
{
public MyTypeMappingConfiguration()
{
// registers int => string mapping,
// where string instances are created with x.ToString() expression,
// where 'x' is the source int value
Configure<int, string>( (x, _) => x.ToString() );
// registers short => string mapping,
// that uses int => string mapping registered in the 'm' ITypeMapper instance
Configure<short, string>( (x, m) => m.Map( ( int )x ).To<string>() );
}
}
There are other, more specialized types of type mapping configurations as well. Such configurations can be used to create a mapper, like so:
// creates a type mapper builder with registered configuration
var builder = new TypeMapperBuilder()
.Configure( new MyTypeMappingConfiguration() );
// crates a type mapper from the current state of the builder
var mapper = builder.Build();
// maps 5 to string, which should return "5", according to the above configuration
var intResult = mapper.Map( 5 ).To<string>();
// maps a collection of shorts to a collection of strings
// should return a collection of 3 strings: "0", "3" and "7"
// result is not materialized
var shortResult = mapper.MapMany<short>( 0, 3, 7 ).To<string>();
There also exist type mapping configuration modules, that allow to create type mapping configuration trees. They can be used to group type mapping configurations together, under one type mapping configuration.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net7.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.