2010-11-29 66 views
2

我註冊automapper使用與以下單位:帶有Unity的Automapper - 在哪裏放置CreateMap的東西?

container 
    .RegisterType<AutoMapper.Configuration, AutoMapper.Configuration>(new PerThreadLifetimeManager(), 
new InjectionConstructor(typeof (ITypeMapFactory), AutoMapper.Mappers.MapperRegistry.AllMappers())) 
    .RegisterType<ITypeMapFactory, TypeMapFactory>() 
    .RegisterType<IConfiguration, AutoMapper.Configuration>() 
    .RegisterType<IConfigurationProvider, AutoMapper.Configuration>() 
    .RegisterType<IMappingEngine, MappingEngine>(); 

這工作得很好,但我在哪裏把我Mapper.CreateMap的相當於?

另外,如果我有一些自定義解析器,我如何以及在哪裏註冊這些地方,他們對我通過Unity註冊的其他對象有依賴關係?

回答

0

一旦你在IoC中註冊了所有東西,從容器中取出IConfiguration實例來註冊自定義解析器&創建映射。

+0

你有這樣的例子嗎? – retslig 2012-12-19 21:10:47

相關問題