public void FuncExpressionTest() { var mapper = new MapperBuilder <TestMap, TestMap>().GetMapperExpressionEx().Compile(); var value = mapper(new TestMap()); Assert.That(value, Is.Not.Null); }
public void ActionExpressionTest() { var mapper = new MapperBuilder <TestMap, TestMap>() .SetProcessCrossReferences(false) .GetMapperExpression() .Compile(); mapper(new TestMap(), new TestMap(), null); }
internal Mapper([NotNull] MapperBuilder <TFrom, TTo> mapperBuilder) => _mapperBuilder = mapperBuilder;
internal Mapper(MapperBuilder <TFrom, TTo> mapperBuilder) => _mapperBuilder = mapperBuilder;
public void PerfTest() { var map = new MapperBuilder <Source, Dest>() .MapMember(_ => _.Field3, _ => _.Field2) .MapMember(_ => _.Field4, _ => _.Field5) .MapMember(_ => _.Field12, _ => _.Field12 != null ? int.Parse(_.Field12) : 12) .MapMember(_ => _.Field13, _ => _.Field13 ?? 13) .MapMember(_ => _.Field14, _ => _.Field14 ?? 14) .GetMapper(); var src = new Source(); var sw = new Stopwatch(); map.Map(src); map.Map(src, null); map.Map(src, null, null); map.GetMapperEx()(src); map.GetMapper()(src, null, null); const int n = 1000000; for (var i = 0; i < n; i++) { sw.Start(); map.Map(src); sw.Stop(); } Console.WriteLine(sw.Elapsed); sw.Reset(); for (var i = 0; i < n; i++) { sw.Start(); map.Map(src, null); sw.Stop(); } Console.WriteLine(sw.Elapsed); sw.Reset(); for (var i = 0; i < n; i++) { sw.Start(); map.Map(src, null, null); sw.Stop(); } Console.WriteLine(sw.Elapsed); sw.Reset(); var map3 = map.GetMapperEx(); for (var i = 0; i < n; i++) { sw.Start(); map3(src); sw.Stop(); } Console.WriteLine(sw.Elapsed); sw.Reset(); var map4 = map.GetMapper(); for (var i = 0; i < n; i++) { sw.Start(); map4(src, null, null); sw.Stop(); } Console.WriteLine(sw.Elapsed); }