Skip to content

Latest commit

 

History

History
31 lines (27 loc) · 1.07 KB

README.md

File metadata and controls

31 lines (27 loc) · 1.07 KB

Object Mapper

A zero-reflection, type-safe object to object mapper.

Getting Started

Map an object to another like this:

  var mapper = new Mapper<TestObjectOne, TestObjectTwo>();
  TestObjectTwo two = GetTestObjectTwo();
  TestObjectOne mappedOne = mapper.Use(TypeMaps.TestObjectOneTestObjectTwoMap).Map(two);

where TypeMaps.TestObjectOneTestObjectTwoMap is an IEnumerable of Funcs that are getters and setters. Like this:

  public static IEnumerable TestObjectOneTestObjectTwoMap
  {
    get
    {
      //Needs one of these per mappable property.
      yield return new PropertyMap<TestObjectOne, TestObjectTwo, string>(
        x => x.StringOne, (s, x) => x.StringOne = s,
        x => x.StringTwo, (s, x) => x.StringTwo = s
      );
    }
  }

There are a few more examples, including a one way map, in the unit test. See MapperTest.cs.

##License and Copyright

See LICENSE