fFastMapper is ready and available via NuGet.
Use "Install-Package fFastMapper"
fFastMapper is a component to map property values between objects.
- Maps are statically defined based upon the types being mapped
- Only a single map exists in the system for mapping object X to object Y
- By default, mappings are bi-directional
- Mappings of complex objects fail silently (no null reference exceptions)
- Mapping actions are performed very quickly
- In my tests of a simple object map run one million times, AutoMapper took about 38 times as long to complete the mapping
- Auto-initializes map on first use based on name and type matching.
AutoMapper took 342,179,880 ticks |
fFastMapper took 8,836,513 ticks |
Direct coded function took 7,004,837 ticks |
Quick Start:
using Grax.fFastMapper;...
var dest = fFastMap.MapperFor<SourceType,DestinationType>(source);
or
var dest = new DestinationType();
fFastMap.Map(source,dest);
or
var dest = new DestinationType()
fFastMap.MapperFor<SourceType,DestinationType>(source, dest);
Global Configuration (affects maps not created yet):
using Grax.fFastMapper;fFastMap
.GlobalSettings()
.SetAutoInitialize(false)
.SetDefaultMappingDirection(fFastMap.MappingDirection.LeftToRight);
Map Configuration (affects property mapping functions (ClearMappers, AddDefaultPropertyMappers, AddPropertyMapper, DeletePropertyMapper that run after this command)
fFastMap.MapperFor<n1, n2>()
.SetMappingDirection(fFastMap.MappingDirection.LeftToRight)
Mapping Functions
fFastMap.MapperFor<n1, n2>()
.ClearMappers()
.AddDefaultPropertyMappers()
.DeletePropertyMapper(left => left.Id)
.AddPropertyMapper(left => left.Id, right => right.Id);
Debugging/Testing Functions
fFastMap.MapperFor<n1,n2>().Mappings() gives you a List of Tuples where the Item1 property is a string representation of the left (source) side of the mapping and the Item2 property is a string representation of the right (destination) side of the mapping.fFastMap.MapperFor<n1,n2>().MappingsView() gives you a string describing all of the mappings for these types.
Tips
ClearMappers will remove all mappings. It will not cause the Map command to fail, just no data will be mapped when that command runs.
Please note that any "MapperFor<n1,n2>" is equivalent to any other. i.e.
var x = fFastMap.MapperFor<n1,n2>();
var z = fFastMap.MapperFor<n1,n2>();
x.ClearMappers();
y.Map(source,dest); // all Mappers were just cleared in previous line. No data transferred.