In my presentation layer I use an MVC pattern with DI to achieve thin controllers like so:
public class HomeController : Controller
{
private IHomeService _service;
public HomeController(IHomeService service)
: base()
{
_service = service;
}
public override ActionResult Index()
{
HomeIndexViewModel viewModel = new HomeIndexViewModel();
viewModel.NewsArticles = _service.GetLatestNewsArticles();
return View(viewModel);
}
}
I'm using Ninject thus I've configured Ninject within the presentation layer like so:
public class NinjectConfig
{
public static IKernel CreateKernel()
{
StandardKernel kernel = new StandardKernel();
kernel.Bind<IHomeService>().To<HomeService>();
kernel.Bind<ISearchService>().To<SearchService>();
return kernel;
}
}
I'm a bit confused as to whether I should be configuring Ninject in the presentation layer, or whether this should be done in the application layer.
I'm also wondering whether it is acceptable to have multiple Ninject configurations in multiple layers, such as a configuration in the application layer and another in the business layer.