dependency injection - Change default scope for all bindings "to" a particular class -


is there way set default scope bindings "to" particular class. instance if have following:

kernel.bind<imyinterface1>.to<mysingletonclass>(); kernel.bind<imyinterface2>.to<mysingletonclass>(); kernel.bind<imyinterface3>.to<mysingletonclass>(); kernel.bind<imyinterface4>.to<mysingletonclass>(); 

i'd of these singleton scoped default. , of following request scoped default:

kernel.bind<imyinterface1>.to<myclass>(); kernel.bind<imyinterface2>.to<myclass>(); kernel.bind<imyinterface3>.to<myclass>(); kernel.bind<imyinterface4>.to<myclass>(); 

all .inxxxscope() methods boil down inscope( callback) method. or make extension method 1 or other depending on parameter.

ninject.extensions.conventions can useful when doing stuff (and has examples of binding multiple interfaces and/or interfaces doing).

most importantly - don't use ninject in tests. reckon you're missing abstraction if need loads of wiring effect important switch this. perhaps autofixture or similar has role play in environment?


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -