in the Users with service layer tutorial, the product service designer is as follows:
ProductService(IValidationDictionary validationDictionary, IProductRepository repository)
and its instance in the default controller constructor is created as follows:
public ProductController()
{
_service = new ProductService(new ModelStateWrapper(this.ModelState), new roductRepository());
}
If I want to use Unity for DI, obviously, the second constructor should be used.
public ProductController(IProductService service)
{
_service = service;
}
But then I don’t know, do not configure Unity to enter the first parameter of ProductServise, because ModelStateWrapper uses the ModelState from the controller, which is created inside the controller and cannot be injected. Is it possible to inject such a dependency to the ProductService?
Erik
source
share