i have 2 constructors defined so:
public interface imyservice<t1,t2>{} public class myservice1 : imyservice<sometypea,sometypeb> { public myservice2(string serviceauri,iserviceb svc){} public myservice2(iservicea svc,iserviceb svc){} } public class myservice2 : imyservice<sometypec,sometyped> { public myservice2(string serviceauri,iserviceb svc){} public myservice2(iservicea svc,iserviceb svc){}
public myservice2(iservicec svc,iserviced svc){} }
i registering multiple service implementations of imyservice on different values of t1 , t2 registration mechanism have generic across implementations of interface.
how can specify constructor invoke without using [inject] attributes? there convention can specify in "bind" guide ninject pick constructor "url" parameter on others?
i recommend not have multiple constructors. situation can think of relevant if not owner of class. e.g. injecting .net library class somewhere. in rare case can define constructor using toconstructor
overload:
int someconstantvalue = 1; func<int> someothervalue = () => random(10); bind<ifoo>.toconstructor(c => new foo(c.inject<ibar>(), someconstantvalue, someothervalue, c.inject<ibaz>());
Comments
Post a Comment