MapperToolkit 1.0.1.7-alpha
This is a prerelease version of MapperToolkit.
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 MapperToolkit --version 1.0.1.7-alpha
NuGet\Install-Package MapperToolkit -Version 1.0.1.7-alpha
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="MapperToolkit" Version="1.0.1.7-alpha" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add MapperToolkit --version 1.0.1.7-alpha
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: MapperToolkit, 1.0.1.7-alpha"
#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 MapperToolkit as a Cake Addin #addin nuget:?package=MapperToolkit&version=1.0.1.7-alpha&prerelease // Install MapperToolkit as a Cake Tool #tool nuget:?package=MapperToolkit&version=1.0.1.7-alpha&prerelease
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
MapperToolkit
a source generator for object-object mapper
Quickstart
Installation
Add the NuGet Package to your project:
dotnet add package MapperToolkit
Create your first mapper
//example Entity
public class Entity
{
public string Account { get; set; }
public DateTime CreateTime { get; set; }
}
//example DTO
public class DTO
{
public string EmpNo { get; set; }
public string EmpName { get; set; }
public DateTime CreateTime { get; set; }
}
Create profile class inherit MapperToolkit.Profile in constructors type mapper code
// Profile declaration
public class MappingProfile : Profile
{
public MappingProfile()
{
GenerateAllMapper<Entity, DTO>()
.Map(src => src.Account[0..4],dest=>dest.EmpNo)
.Map(src => src.Account[4..^0],dest=>dest.EmpName);
}
}
//Generator code
public static partial class DTOMapper
{
public static global::ConsoleApp.DTO MapperToDTO(this global::ConsoleApp4.Entity source)
{
global::ConsoleApp4.DTO result = new();
global::System.Func<global::ConsoleApp.Entity, string> EmpNoMapper = src => src.Account[0..4];
global::System.Func<global::ConsoleApp.Entity, string> EmpNameMapper = src => src.Account[4..^0];
result.EmpNo = EmpNoMapper.Invoke(source);
result.EmpName = EmpNameMapper.Invoke(source);
result.CreateTime = source.CreateTime;
return result;
}
}
//Mapper usage
var entity = new Entity() { Account = "A123Bojack" ,CreateTime = DateTime.Now };
var dto = entity.MapperToDTO();
Console.WriteLine($"EmpNo:{dto.EmpNo};EmpName:{dto.EmpName};CreateTime:{dto.CreateTime}");
// print EmpNo:A123;EmpName:Bojack;CreateTime:2022/8/16 12:13:15
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. 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. |
.NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.1
- 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 |
---|---|---|
1.0.2.2 | 438 | 9/1/2022 |
1.0.2.1 | 387 | 9/1/2022 |
1.0.2 | 394 | 9/1/2022 |
1.0.1.9-alpha | 156 | 8/18/2022 |
1.0.1.8-alpha | 145 | 8/17/2022 |
1.0.1.7-alpha | 148 | 8/16/2022 |
1.0.1.6-alpha | 140 | 8/16/2022 |
1.0.1.5-alpha | 148 | 8/16/2022 |
1.0.1.4-alpha | 146 | 8/16/2022 |
1.0.1.3-alpha | 151 | 8/16/2022 |
1.0.1.2-alpha | 155 | 8/15/2022 |
1.0.1.1-alpha | 154 | 8/15/2022 |
1.0.1-alpha | 147 | 8/15/2022 |
1.0.0-alpha | 159 | 8/15/2022 |