static void Main(string[] args) { Console.WriteLine("Hello World!"); var mapper = new ReMapper(); mapper.AddBuilder <Test, Test2>() .MapField("Id") .MapField(from => from.Number, to => to.Number, i => i.ToString()) .MapField("FirstName", "Name") .Reverse() .MapField(nameof(Test2.Id)) .MapField(c => c.Name, to => to.FirstName) .MapField(from => from.Number, to => to.Number, s => int.Parse(s)) .Build(); mapper.AddBuilder <TestList, TestList2>() .MapField("Name") .MapField(to => to.Count, from => from.List.Count) .MapField(from => from.List, to => to.List) .Reverse() .MapAll() .Build(); var test = new Test { Id = "Test", Number = 2, FirstName = "Name" }; var list = new TestList { Name = "Test", List = new List <Test> { test } }; var test2 = new Test2(); var test3 = mapper.Convert(test, test2); var testlist2 = mapper.Convert <TestList, TestList2>(list); var testlist = mapper.Convert <TestList2, TestList>(testlist2); Console.ReadLine(); }
public MapBuilder(ReMapper reMapper) { _reMapper = reMapper; }
public static MapBuilder <TSource, TResult> AddBuilder <TSource, TResult>( this ReMapper reMapper) { return(new MapBuilder <TSource, TResult>(reMapper)); }