c# - castle windsor service overrides for overriding default -
c# - castle windsor service overrides for overriding default -
i wondering there pattern in windsor next scenario.
basically have service (defaultservice) registered, , have plugin in want replace service (defaultservice) (pluginbasedservice) instances.
i'm using hack - kernel.removecomponent(), re-adding plugin-based service. seems hacky. ihandleselector seems hacky scenario well.
the autofac approach of resolving "last registered" service work me.
cheers, chris
public class vm { public vm(iservice) { } } public interface iservice {} public class defaultservice : iservice {} public class pluginbasedservice : iservice {} container.register( component.for<iservice>().implementedby<defaultservice>(), component.for<vm>() ); // called in dynamically loaded assembly, after default service has been registered container.register( component.for<pluginbasedservice>() .serviceoverrides(serviceoverride.forkey<iservice>.eq<pluginbasedservice>()) ); container.resolve<iservice>() // defaultservice -> want "pluginbasedservice"
i'm not sure understand question (perhaps rewrite it, it's not clear you're after), if understand correctly, you're after able utilize different component given service in context.
if that's indeed case think either ihandlerselector
or kid container might provide way accomplish that.
c# castle-windsor
Comments
Post a Comment