Inject multiple service implementations with Castle Windsor
Asked Answered
R

1

9

I would like to have Windsor inject multiple implementations of a service to a constructor.

My scenario is that I have multiple search providers that implement a common interface. I would like to register each of these with windsor and then inject them into my search service so it can query each on in turn.

Is such a thing possible with Windsor? Is there a better approach than injecting multiple implementations into the constructor?

Rexanna answered 4/1, 2009 at 9:33 Comment(0)
S
10

See Inversion of Control and Dependency Injection with Castle Windsor Container - Part II at DotNetSlackers. It shows how to pass an array of the same service interface to an object.

Swahili answered 4/1, 2009 at 9:39 Comment(2)
It would be nice to see a non-xml config version of this articleFruma
Similar, but using fluent config: mikehadlow.blogspot.com/2009/03/…Conquer

© 2022 - 2024 — McMap. All rights reserved.