FunctionSimpleMapper 1.0.2

dotnet add package FunctionSimpleMapper --version 1.0.2                
NuGet\Install-Package FunctionSimpleMapper -Version 1.0.2                
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="FunctionSimpleMapper" Version="1.0.2" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add FunctionSimpleMapper --version 1.0.2                
#r "nuget: FunctionSimpleMapper, 1.0.2"                
#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 FunctionSimpleMapper as a Cake Addin
#addin nuget:?package=FunctionSimpleMapper&version=1.0.2

// Install FunctionSimpleMapper as a Cake Tool
#tool nuget:?package=FunctionSimpleMapper&version=1.0.2                

SimpleMapper

The Simplest mapper possible with DI included. Define the mapper function in once side and use it everywhere

How to use it

You can get the service from the serviceProvider

var mapper = serviceProvider.GetService<ISimpleMapper>();

Or use the interface in your class.

public Controller(ISimpleMapper simpleMapper){
    ...
}

Then you can map the object specifying the source and target class.

var userDto = simpleMapper.Map<User, UserDTO>(user);

or just the source class. You can only set only class using this way.

var userDto = simpleMapper.Map<User>(user);

How to create Mapper classes

Implement the IClassMapper. Then the FunctionSimpleMapper.Extensions will get the binding function.

public class UserMapper : IClassMapper
{
    public void Bind(ISimpleMapper mapper)
    {
        mapper.Bind((User s) => new UserDTO()
            {
                Id = s.Id,
                Name = s.Name,
            });
    }
}

Add the service to de ServiceCollection.

var serviceProvider = new ServiceCollection()
                .AddSimpleMapper() <-- Add this line
                .BuildServiceProvider();
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 (1)

Showing the top 1 NuGet packages that depend on FunctionSimpleMapper:

Package Downloads
FunctionSimpleMapper.Extensions

Simple Function Mapper Library Extentions library

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.2 155 3/5/2024