Hypercubus.Mapping
0.6.0
dotnet add package Hypercubus.Mapping --version 0.6.0
NuGet\Install-Package Hypercubus.Mapping -Version 0.6.0
<PackageReference Include="Hypercubus.Mapping" Version="0.6.0" />
<PackageVersion Include="Hypercubus.Mapping" Version="0.6.0" />
<PackageReference Include="Hypercubus.Mapping" />
paket add Hypercubus.Mapping --version 0.6.0
#r "nuget: Hypercubus.Mapping, 0.6.0"
#:package Hypercubus.Mapping@0.6.0
#addin nuget:?package=Hypercubus.Mapping&version=0.6.0
#tool nuget:?package=Hypercubus.Mapping&version=0.6.0
![]()
Hypercubus Mapper
A fast and minimalist object to object mapper for .Net.
Usage
All the configured mapping is managed by the Hypercubus.Mapping.Mapper class. You can use it with your favorite dependency injection framework to inject the mapper instance in your Asp.Net controller classes.
Configuration
services.AddSingleton(sc =>
{
var mapper = new Hypercubus.Mapping.Mapper();
mapper.Configure<Phone, PhoneDto>((m, s) => new PhoneDto()
{
Id = s.Id,
Number = s.Number
});
mapper.Configure<User, UserDto>((m, s) => new UserDto()
{
Id = s.Id,
UserName = s.UserName
});
mapper.Configure<Person, PersonDto>((m, s) => new PersonDto()
{
Id = s.Id,
Name = s.Name,
Age = s.Age,
UserLog = m.Map(s.UserLog).To<UserDto>(), // New Syntax!
Phones = m.Map<List<Phone>, PhoneDto[]>(s.Phones)
});
return mapper;
});
IEnumerable, Array, and List configurations are automatically added to your configured types by default. You can disable this for a individual Type by using the overload of the Configure method that has a addDefaultEnumerableTypes parameter.
Mapper Usage
After injecting it in your controllers just make a simple call like this:
List<PersonDto> personsDto = mapper.Map(persons).To<List<PersonDto>>();
If you use a single set of mapping rules, i.e. a single Mapper class, you can use a shorter and easier to write mapping extension method:
List<PersonDto> personsDto = persons.Map().To<List<PersonDto>>();
This will be based on the default Mapper which is the first Mapper created in the current process and can also be changed when needed:
Mapper.ChangeDefault(alternateMapper);
Why use this library?
WYSIWYG and No Complex Configurations
Keep it Simple, Silly 😉
Validate your Mappings Rules at Compile Time
Fully automated mapping might seem useful, but it can become a problem when properties are changed or renamed and things stop working and the team doesn't immediately know why. Hypercubus.Mapping always enforces the use of explicit mappings that avoid this kind of situation.
Similar or even Faster than Traditional Handwritten Code
Why write mappings code by hand every time when you can make this process standard and reuse mapping rules by adopting a mapper library? And with a big plus that makes your code run FASTER.
With very simple POCO classes, Hypercubus Mapper runs typically in a time equivalent to handwriting and rarely adds a maximum of 9% time overhead. Still, when classes become more complex - with other classes referenced - it can save up to 46% mapping processing time.
Pure .NET Standard 2.0 Code with No Dependencies
This library does not use Reflection.Emit package so it can be used in Xamarin, Mono, and UWP projects without a problem.
Allows Multiple Profiles
To add multiple profiles just create another Mapper instance and configure its mappings.
Performance and Memory efficiency
Great performance and low memory footprint using lightweight c# features like delegates and structs plus some nice caching techniques.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 is compatible. net5.0-windows was computed. net6.0 is compatible. 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 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 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. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 is compatible. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- No dependencies.
-
.NETStandard 2.1
- No dependencies.
-
net5.0
- No dependencies.
-
net6.0
- No dependencies.
-
net7.0
- No dependencies.
-
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.6.0 | 327 | 1/11/2024 |
| 0.5.2 | 6,398 | 6/9/2022 |
| 0.4.2 | 582 | 5/31/2022 |
| 0.3.1 | 854 | 3/29/2022 |
| 0.2.7 | 607 | 3/28/2022 |
| 0.2.6 | 607 | 3/28/2022 |
| 0.2.5 | 598 | 3/21/2022 |
| 0.2.1 | 594 | 3/12/2022 |
| 0.2.0 | 682 | 2/18/2022 |
| 0.1.15 | 629 | 2/15/2022 |
| 0.1.14 | 597 | 2/13/2022 |
| 0.1.10 | 606 | 2/13/2022 |
| 0.1.7 | 606 | 2/10/2022 |
| 0.1.6 | 620 | 2/10/2022 |
| 0.1.5 | 602 | 2/10/2022 |
| 0.1.4 | 593 | 2/10/2022 |
* Some minor improvements
* Added net5.0, net6.0, net7.0 and net8.0