Flaminco.ManualMapper
1.0.1
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package Flaminco.ManualMapper --version 1.0.1
NuGet\Install-Package Flaminco.ManualMapper -Version 1.0.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="Flaminco.ManualMapper" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Flaminco.ManualMapper --version 1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Flaminco.ManualMapper, 1.0.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 Flaminco.ManualMapper as a Cake Addin #addin nuget:?package=Flaminco.ManualMapper&version=1.0.1 // Install Flaminco.ManualMapper as a Cake Tool #tool nuget:?package=Flaminco.ManualMapper&version=1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Introduction
this package trying to set a structured method for implementing object mapping in both ways (Sync, Async)
Getting Started
inject mapper scanner
builder.Services.AddManualMapper<Program>();
lets start with an example
//Source Object
public class Person
{
public int Age { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
}
// Destination Object
public class PersonResponse
{
public int Age { get; set; }
public string FullName { get; set; }
}
// class to represent the mapping logic.
public class PersonMapper : IMapHandler<Person, PersonResponse>
{
public PersonResponse Handler(Person source)
{
return new PersonResponse
{
Age = source.Age,
FullName = $"{source.FirstName} {source.LastName}"
};
}
}
public class PersonController : ControllerBase
{
private readonly IManualMapper _mapper;
public PersonController(IManualMapper mapper)
{
_mapper = mapper;
}
[HttpGet]
public PersonResponse Get()
{
return _mapper.Map<Person, PersonResponse>(new Person
{
Age = 1,
FirstName = "Ahmed",
LastName = "Abuelnour"
});
}
}
Same example goes for Async Mapper, bus instead of using IMapHandler
use IMapAsyncHandler
and instead of using _mapper.Map
use _mapper.MapAsync
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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net7.0
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.