我希望将Automapper注册到Simple Injector,以便将其注入到控制器中:
public class MyController : BaseController
{
private IUnitOfWork unitOfWork;
private IMappingEngine mappingEngine;
public PatientController(IUnitOfWork _unitOfWork, IMappingEngine _mappingEngine)
{
this.unitOfWork = _unitOfWork;
this.mappingEngine = _mappingEngine;
}
}
然而,当我尝试注册它时。
public static void Initialize()
{
//Code for registering our repository class and DI
var container = new Container();
container.Register<IUnitOfWork, UnitOfWork>();
container.Register<IMappingEngine, MappingEngine>();
container.RegisterMvcControllers(Assembly.GetExecutingAssembly());
DependencyResolver.SetResolver(
new SimpleInjectorDependencyResolver(container));
}
我遇到了一个错误:
容器需要确切地包含一个公共构造函数,才能创建MappingEngine,但它有2个。
参数名称:TImplementation。
我做错了什么?