static void Main(string[] args)
        {
            AutoMapper.Mappers.MapperRegistry.Reset();
            var autoMapperCfg = new AutoMapper.ConfigurationStore(new TypeMapFactory(), AutoMapper.Mappers.MapperRegistry.Mappers);
            var mappingEngine = new AutoMapper.MappingEngine(autoMapperCfg);

            autoMapperCfg.Seal();

            autoMapperCfg.CreateMap <Entity1, Entity2>().ReverseMap();
            var a1 = new Entity1();
            var b1 = mappingEngine.Map <Entity2>(a1);

            var colEntity1 = new List <Entity1> {
                new Entity1()
                {
                    DepId = 1, Name = "abc"
                }, new Entity1()
                {
                    DepId = 2, Name = "qwe"
                }, new Entity1()
                {
                    DepId = 3, Name = "qaz"
                }
            };

            var colEntity2 = new List <Entity2> {
                new Entity2()
                {
                    DepId = 2, Name = "newNameFirst"
                }, new Entity2()
                {
                    DepId = 3, Name = "newNameSecond"
                }, new Entity2()
                {
                    DepId = 4, Name = "newName"
                }
            };

            //Mapper.Initialize(cfg => cfg.CreateMap<Entity1, Entity2>());
            CompareCollections <Entity1, Entity2> .Compare(colEntity1, colEntity2, x => x.DepId);
        }
예제 #2
0
 public void Initialize(ConfigurationStore configurator)
 {
     _configurator = configurator;
 }
예제 #3
0
 public void Initialize(ConfigurationStore configurator)
 {
     _configurator = configurator;
     _configurator._formatterProfiles.AddOrUpdate(ProfileName, this, (s, configuration) => this);
 }