/// <summary> /// Hards the map. /// </summary> /// <param name="s">The s.</param> /// <returns>A SimpleTypesDestination.</returns> public static SimpleTypesDestination HardMap(SimpleTypesSource s) { SimpleTypesDestination result = new(); result.Str1 = s.Str1; result.Str2 = s.Str2; result.Str3 = s.Str3; result.Str4 = s.Str4; result.Str5 = s.Str5; result.Str6 = s.Str6; result.Str7 = s.Str7; result.Str8 = s.Str8; result.Str9 = s.Str9; result.N1 = s.N1; result.N2 = (int)s.N2; result.N3 = s.N3; result.N4 = s.N4; if (s.N5.HasValue) { result.N5 = decimal.ToInt32(s.N5.Value); } result.N6 = (int)s.N6; result.N7 = s.N7; result.N8 = s.N8; return(result); }
public void Setup() { var fixture = new Fixture(); _benchSourceEmitMapper = Mapper.Default.GetMapper <BenchNestedSource, BenchNestedDestination>(); _simpleEmitMapper = Mapper.Default.GetMapper <SimpleTypesSource, SimpleTypesDestination>(new DefaultMapConfig()); var config = new MapperConfiguration( cfg => { cfg.CreateMap <BenchNestedSource, BenchNestedDestination>(); cfg.CreateMap <BenchNestedSource.Nested2, BenchNestedDestination.Inner2>(); cfg.CreateMap <BenchNestedSource.Nested1, BenchNestedDestination.Inner1>(); cfg.CreateMap <SimpleTypesSource, SimpleTypesDestination>(); }); _autoMapper = config.CreateMapper(); _benchSource = fixture.Create <BenchNestedSource>(); _simpleSource = fixture.Create <SimpleTypesSource>(); _simple100List = fixture.CreateMany <SimpleTypesSource>(100).ToList(); _simple1000List = fixture.CreateMany <SimpleTypesSource>(1000).ToList(); _benchSources1000List = fixture.CreateMany <BenchNestedSource>(1000).ToList(); this.BenchNested1000_a_HardMapper(); this.BenchNested1000_b_EmitMapper(); this.BenchNested1000_c_AutoMapper(); this.Bench_a_HardMapper(); this.Bench_b_EmitMapper(); this.Bench_c_AutoMapper(); this.SimpleTypes1000_a_HardMapper(); this.SimpleTypes1000_b_EmitMapper(); this.SimpleTypes1000_c_AutoMapper(); this.SimpleTypes100_a_HardMapper(); this.SimpleTypes100_b_EmitMapper(); this.SimpleTypes100_c_AutoMapper(); this.SimpleTypes_a_HardMapper(); this.SimpleTypes_b_EmitMapper(); this.SimpleTypes_c_AutoMapper(); }