FunctionSimpleMapper 1.0.2
dotnet add package FunctionSimpleMapper --version 1.0.2
NuGet\Install-Package FunctionSimpleMapper -Version 1.0.2
<PackageReference Include="FunctionSimpleMapper" Version="1.0.2" />
paket add FunctionSimpleMapper --version 1.0.2
#r "nuget: FunctionSimpleMapper, 1.0.2"
// 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 | Versions 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. |
-
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 | 159 | 3/5/2024 |