Reputation: 7092
How can I load referenced modules within one of my Ninject's module. For an example, I have Business layer module, which depends on DataAccess module, but current I have to do something like this:
Business.Module {
class Module{
public void Load()
{
//add bindings
}
}
}
DataAccess.Module {
class Module{
public void Load()
{
//add repositories bindings
}
}
}
and then within the app., I have to use the both:
class ControllerFactory
{
NinjectKernel kernel = new NinjectKernel(
new Business.Module(),
new DataAccess.Module())
}
but my goal is to separate app and data layer, so app. must refer only business layer, which refer data layer.
I know how it could be done using Unity container. But what about Ninject?
Upvotes: 0
Views: 168
Reputation: 527
You can create a separate project for this. It is safe to reference your DAL and Business layer from it since it doesn't contain any logic except configuring your composition root. Then reference to this project from your GUI project. It might seems like an overhead but it works perfect in my experience.
Upvotes: 1