c# - How to inject the same instance of a class with Ninject? -


i using ninject ioc. have following classes.

// repository public class efproductrepository : iproductrepository, iunitofworkrepository {   private iunitofwork unitofwork;   private efdbcontext efdbcontext;    public efproductrepository(iunitofwork uow)   {     unitofwork = uow;     efdbcontext = new efdbcontext();   }   // }  // controller public class productcontroller : controller {   private iunitofwork unitofwork;   private iproductrepository productrepository;    public productcontroller(iunitofwork uow, iproductrepository repo)   {     unitofwork = uow;     productrepository = repo;   } } 

currently ninject bindings follow assign new instance of concrete class interface.

ninjectkernel.bind<iunitofwork>().to<unitofwork>(); ninjectkernel.bind<iproductrepository>().to<efproductrepository>(); 

using ninject controller factory, need inject same instance of iunitofwork class productcontroller , efproductrepository. please guide me.


Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

VBA function to include CDATA -