Well I'm learning to work with dependency injection now and would like to apply it to my project. However I came across the following difficulty, I have a base controller where it is inherited by three other base controllers that perform the overload and thus I can perform all the necessary functions in my system. However when trying to apply the dependency injunction the child classes ask me to pass the constructor object, then I would like to know how to handle it.
I'm using unity to do dependency injection.
Below is the parent controller code:
public class BaseController : ApiController
{
public string[] includes = null;
private readonly IFiltroServico servico;
public BaseController(IFiltroServico _servico)
{
servico = _servico;
}
}
Child contoller, here the error is generated because it is necessary to pass the IFiltroService due to the constructor of the parent class:
public abstract class BaseController<R> : BaseController
where R : class
{
//services da controller;
}
I want to know how best to do this and how to pass the constructor from here .