Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Inject multiple service implementations with Castle Windsor

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?

like image 789
Brownie Avatar asked Jan 04 '09 09:01

Brownie


1 Answers

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.

like image 54
Roger Lipscombe Avatar answered Oct 10 '22 01:10

Roger Lipscombe