Most of the examples I\'ve found for Automapper use the static Mapper object for managing type mappings. For my project, I need to inject an IMapperEngine as part of object
Here's what I ended up with as I couldn't figure out how to set the configuration on Mapper.Engine and have it passed into For().Use.
public MyRegistry()
{
For().Use();
For().Use();
//type mapping
For()
.Singleton()
.Use(ctx =>
{
ITypeMapFactory factory = ctx.GetInstance();
ConfigurationStore store
= new ConfigurationStore(factory, MapperRegistry.AllMappers());
IConfiguration cfg = store;
cfg.AddProfile();
store.AssertConfigurationIsValid();
return store;
});
For().Use(ctx => ctx.GetInstance());
For().Use(ctx => ctx.GetInstance());
For().Singleton().Use();
For().Use();
}