I use S#arp Architecture which uses Windsor Castle for IoC. I got a new controller now that, unlike all other controllers in the project, need a different implementation of the same interfaces. I.e. all controllers use ProductsRepository: IProductsRepository as implementation, but the new one has to use SpecificProductsRepository.
How do I configure it to recognize and manage this automatically? Either in pure Windsor way, or with ASP.NET MVC help (e.g. in my custom controllers factory).
OK looks like I need subcontainers. Still searching.
An easier and much simpler way would be to use Windsor’s service overrides.
E.g. register your repos like so:
which will ensure that the default implementation is
ProductsRepository. Now, for your specific controller, add a service override like so:You can read the docs here.
Edit: If you want to register your repositories with
AllTypes, you can adjust the registration key e.g. like so:where
GetKeye.g. could be something like: