Mapper is a simple property mapper for c# Converter classes. We started with AutoMapper but decided it required configuration that turned into black magic.
Here we present a simple mapper that copies values from properties in type A to type B if the names and property types match. We will add to this project as our needs grow.
User source = new User();
Customer destination = source.MapTo<Customer>();
User source = new User();
Customer destination = new Customer();
destination.MapFrom(source);
User source = new User();
Customer destination = new Customer();
new SimpleMapper().Map(source, destination);
const int age = 26;
const string name = "James";
var user = new User { Name = name, Age = age };
var customer = _someConverter.Convert(user);
var expectedCustomer = new Customer { Name = name, Age = age };
var tester = new MappingTester<Customer>();
var result = tester.Verify(customer, expectedCustomer)
result.IsValid.ShouldBeTrue();
The build script requires Ruby with rake installed.
- Run
InstallGems.bat
to get the ruby dependencies (only needs to be run once per computer) - open a command prompt to the root folder and type
rake
to execute rakefile.rb
If you do not have ruby:
- open src\MvbaMapper.sln with Visual Studio and build the solution
This project is part of MVBA's Open Source Projects.
If you have questions or comments about this project, please contact us at mailto:[email protected].