LfrlAnvil.Mapping
0.1.1
See the version list below for details.
dotnet add package LfrlAnvil.Mapping --version 0.1.1
NuGet\Install-Package LfrlAnvil.Mapping -Version 0.1.1
<PackageReference Include="LfrlAnvil.Mapping" Version="0.1.1" />
paket add LfrlAnvil.Mapping --version 0.1.1
#r "nuget: LfrlAnvil.Mapping, 0.1.1"
// Install LfrlAnvil.Mapping as a Cake Addin #addin nuget:?package=LfrlAnvil.Mapping&version=0.1.1 // Install LfrlAnvil.Mapping as a Cake Tool #tool nuget:?package=LfrlAnvil.Mapping&version=0.1.1
(root)
LfrlAnvil.Mapping
This project contains an object mapper, as well as a builder of such a mapper.
Documentation
Technical documentation can be found here.
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. |
-
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.