Sunday 8 September 2013

Ninject Add Binding over the whole assembly / Getting a list of class name in solution

Ninject Add Binding over the whole assembly / Getting a list of class name
in solution

I am using Ninject to do Dependency Injection. So I would have some code
like this
ninjectKernel = new StandardKernel();
ninjectKernel.Bind<Interface1>().To<Class1>();
ninjectKernel.Bind<Interface2>().To<Class2>();
and so on. Problem is that I have like 30-50 class in one project and I
have 8 projects currently (more to add later). So is there a way to scan
over my entire solution and give me a list of interface/classes name? This
will enable me to make a for loop like
for (...) {ninjectKernel.Bind<Interface[i]>().To<Class[i]>();}
Or is there a shortcut way in Ninject?

No comments:

Post a Comment