Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
C# Property Value Mapper
C# Shell
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
settings
src
tools/NUnit
.gitignore
Build.bat
InstallGems.bat
License.txt
Provenance.txt
README.md
RakeFile
Ruby_Not_Installed.txt
go.bat

README.md

Mapper ReadMe

Description

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.

Samples

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);

Testing class mappings

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();

How To Build:

The build script requires Ruby with rake installed.

  1. Run InstallGems.bat to get the ruby dependencies (only needs to be run once per computer)
  2. open a command prompt to the root folder and type rake to execute rakefile.rb

If you do not have ruby:

  1. You need to create a src\CommonAssemblyInfo.cs file. Go.bat will copy src\CommonAssemblyInfo.cs.default to src\CommonAssemblyInfo.cs
  2. open src\MvbaMapper.sln with Visual Studio and build the solution ### License

MIT License

This project is part of MVBA's Open Source Projects.

Something went wrong with that request. Please try again.