之前我使用过Autofac,但现在我想尝试一下SimpleInjector.我的问题是,在我的方法中调用mappingEngine时,我收到以下错误:
缺少类型映射配置或不支持的映射.
映射类型:Something - > SomethingDto目标路径:IEnumerable`1 [0]
来源价值:
_mappingEngine.Map<IEnumerable<SomethingDto>>(IEnumerableOfSomething);
^-- doesn't work
Mapper.Map<IEnumerable<SomethingDto>>(IEnumerableOfSomething);
^-- works (That's not what I want)
Run Code Online (Sandbox Code Playgroud)
Mapper.Map不是我想要的.我在这里注册Automapper:
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>();
Run Code Online (Sandbox Code Playgroud)
Mapper.Initialize(x =>
{
var profiles = container.GetAllInstances<Profile>();
foreach (var profile in profiles)
{
x.AddProfile(profile);
}
});
Mapper.AssertConfigurationIsValid();
Run Code Online (Sandbox Code Playgroud)
我的问题是,如何在SimpleInjector中注册IMappingEngine并正确添加我的个人资料?
提前致谢!
迎接mtrax