c# - Ninject resolve all for interface type -


    public selectuserquery: iquery{         public string command {             get{ return "...."; }         }     }      public class querydispatcher : iquerydispatcher     {         //...          //..          public void dispatch<tquery>(tquery query) tquery : iquery         {             foreach (var handler in kernel.resolveall<iqueryhandler<tquery>>())             {                 handler.handle(query);             }         }     }      public class querymanager{          //...          public activate(){             querydispatcher.dispatch(new selectuserquery());         }     } 

this resolving types used querydispatcher.dispatch(new selectuserquery());

but creating private method in querymanager run dispatch operations this:

public class querymanager{          //...          public seletectuser(){             apply(new selectuserquery());         }          private apply(iquery query){             querydispatcher.dispatch(query);         }     } 

this not working. kernel.resolveall<iqueryhandler<tquery>>() returning empty collection.

bindings this:

public class servicemodule: ninjectmodule {     public override void load()     {         kernel.bind<iqueryhandler<selectuserquery>>().to<selectuserqueryhandler>();         kernel.bind<iquerydispatcher>().to<querydispatcher>();     } } 


Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -