c# - How to depend by parent class -


i have class handler. in constructor have manager class depends on different settings.

kernel.bind<ihandler>().to<handler>().                 withconstructorargument("manager",                  new manager(kernel.get<idataaccessfactory>().createunitofwork(), new custom1settings())); 

how create injection custom1settings in manager , in handler

 class handler {     handler(imanager manager....)     {         ...     } }  class manager {     manager(iunitofwork unit, isettings settings)     {         ...     } } 

ninject automatically figures out dependencies. it's 1 of it's useful features.

define binding custom1settings , manager , automatically inject it.

so

kernel.bind<imanager>().to<manager>(); kernel.bind<icustom1settings>().to<custom1settings>(); 

Comments

Popular posts from this blog

curl - PHP fsockopen help required -

HTTP/1.0 407 Proxy Authentication Required PHP -

c# - Resource not found error -