I used Autofac before, but now I want to try SimpleInjector. My problem is that when calling mapEngine in my method, I get the following error:
Missing type configuration or unsupported mapping.
Display Types: Something → SomethingDto Destination Path: IEnumerable`1 [0]
Original value:
_mappingEngine.Map<IEnumerable<SomethingDto>>(IEnumerableOfSomething); ^-- doesn't work Mapper.Map<IEnumerable<SomethingDto>>(IEnumerableOfSomething); ^-- works (That not what I want)
Mapper.Map is not what I want. I am registering Automapper based on this here:
Replace Ninject with a simple injector
container.Register<ITypeMapFactory, TypeMapFactory>(); container.RegisterAll<IObjectMapper>( MapperRegistry.AllMappers()); container.RegisterSingle<ConfigurationStore>(); container.Register<IConfiguration>(() => container.GetInstance<ConfigurationStore>()); container.Register<IConfigurationProvider>(() => container.GetInstance<ConfigurationStore>()); container.Register<IMappingEngine, MappingEngine>();
Mapper.Initialize(x => { var profiles = container.GetAllInstances<Profile>(); foreach (var profile in profiles) { x.AddProfile(profile); } }); Mapper.AssertConfigurationIsValid();
My question ist, how can I register IMappingEngine in SimpleInjector and correctly add my profiles?
Thanks in advance!
Greetings mtrax
mapping simple-injector profile automapper
mtrax
source share