Skip to content

chrishalebarnes/ObjectMapper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages