LfrlAnvil.Mapping 0.2.1

dotnet add package LfrlAnvil.Mapping --version 0.2.1
NuGet\Install-Package LfrlAnvil.Mapping -Version 0.2.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="LfrlAnvil.Mapping" Version="0.2.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add LfrlAnvil.Mapping --version 0.2.1
#r "nuget: LfrlAnvil.Mapping, 0.2.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install LfrlAnvil.Mapping as a Cake Addin
#addin nuget:?package=LfrlAnvil.Mapping&version=0.2.1

// Install LfrlAnvil.Mapping as a Cake Tool
#tool nuget:?package=LfrlAnvil.Mapping&version=0.2.1

(root) NuGet Badge

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 Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.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.

Version Downloads Last updated
0.2.1 70 6/16/2024
0.2.0 67 6/16/2024
0.1.1 69 5/29/2024
0.1.0 73 5/26/2024