我一直在使用AutoMapper一段时间。我有一个配置文件设置,如下所示:使用Autofac的AutoMapper配置文件IoC
public class ViewModelAutoMapperConfiguration : Profile
{
protected override string ProfileName
{
get { return "ViewModel"; }
}
protected override void Configure()
{
AddFormatter<HtmlEncoderFormatter>();
CreateMap<IUser, UserViewModel>();
}
}
我添加此使用下面的调用映射器:
Mapper.Initialize(x => x.AddProfile<ViewModelAutoMapperConfiguration>());
不过,我现在想传递的依赖将使用国际奥委会ViewModelAutoMapperConfiguration
构造。我正在使用Autofac。我一直在阅读这篇文章:http://www.lostechies.com/blogs/jimmy_bogard/archive/2009/05/11/automapper-and-ioc.aspx,但我不明白这将如何与配置文件一起工作。
任何想法? 谢谢