2010-11-29 61 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