예제 #1
0
        public void FuncExpressionTest()
        {
            var mapper = new MapperBuilder <TestMap, TestMap>().GetMapperExpressionEx().Compile();

            var value = mapper(new TestMap());

            Assert.That(value, Is.Not.Null);
        }
예제 #2
0
        public void ActionExpressionTest()
        {
            var mapper = new MapperBuilder <TestMap, TestMap>()
                         .SetProcessCrossReferences(false)
                         .GetMapperExpression()
                         .Compile();

            mapper(new TestMap(), new TestMap(), null);
        }
예제 #3
0
 internal Mapper([NotNull] MapperBuilder <TFrom, TTo> mapperBuilder) => _mapperBuilder = mapperBuilder;
예제 #4
0
파일: Mapper.cs 프로젝트: lovaya/CodeJam
 internal Mapper(MapperBuilder <TFrom, TTo> mapperBuilder) => _mapperBuilder = mapperBuilder;
예제 #5
0
        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);
        }