inversion of control - How to Install a module that needs an instance per something else that is registered in Castle Windsor -


i trying hang of ioc , di , using castle windsor. have object have created can multiply instantiated on different generic types. example

mytype<generic, generic2> 

on installation of mytype's assembly

container.register(component.for(typeof (imytype<>)).implementedby(typeof (mytype<>))); 

then in main modules initialization install mytypes module mytypeinstaller iwindsorinstaller.

then manually resolving various types of mytype want (this spread around different installers). like

container.resolve<imytype<type1, type2>(); 

that creates actual instance of mytype registered generic types passed in.

this works fine, instances of mytype<,> need created.

now, have module have created install last. want say,

container.resolveall<imytype<,>>()  

then create instances of new object each object exists.

however cant seem resolve of imytypes<,> without knowing concrete types each 1 instantiated as.

at rate, possible doing wrong , want feedback in general well.

first, if mytype<t1,t2> can instantiated once each combination of t1,t2 should registering singleton.

second, cannot call type container methods (like resolveall<t>) open generic - must closed type.

third, mytype open generic type , number of closed generic classes infinite (generic type constraints not considered container). so, far container concerned can call resolve<anything, anythingelse> , attempt provide mytype<anything,anythingelse> you. if , anythingelse don't satisfy type constraints run time error.

even if call resolveall<imytype<,>>() expect return given have registered open generic implementation?


Popular posts from this blog