I need to configure different implementations of some interface, and make it resolve based on Web.config setting.
So that, having IExternalService interface I would like to have TestExternalService and ExternalService one. And I have “TestMode” app setting in Web.config.
How can I register TestExternalService and ExternalService in Castle Windsor, so that when, for example, TestMode is 0, then ExternalService is resolved, and when TestMode is 1, then TestExternalService is resolved.
I need to configure different implementations of some interface, and make it resolve based
Share
I would recommend taking one of two approaches. If you have a large number of services that need to change based on this setting then I would implement two versions of the IWindsorInstaller interface and load the correct one based on the web.config setting.
If you only have one or two services that need to change you can write one instance of IWindsorInstaller and put the logic for registering the component inside the installer.