I have a very layered MVC3 application (seperate projects for the domain, services, web, infrastructure, etc.)
I understand the concept of controller constructor injection, which MVC3 and Ninject work so kindly together. But what about injection for layers separate from the web layer?
For example, I have a service that relies on a Repository interface. The service is called from the controller, and the service itself will be injected properly by the constructor injection, but what about the repository? How do I inject that?
public class MyService
{
protected virtual IPersonRepository PersonRepository {get; set;}
public virtual void UseRepository()
{
PersonRepository.FindEveryoneInTheWorldButDontReturnThem();
}
}
Where/how do I [n]inject the repository in the above example?
Ninject 3.0 Ninject.Web.MVC 3.0