Collection of dependencies in castle windsor
- by jonnii
I have the following scenario:
public class FirstChildService : IChildService { }
public class SecondChildService : IChildService { }
public class MyService : IService {
public MyService(IEnumerable<IChildService> childServices){ ... }
}
I'm currently registering all the child services and explicitly depending on them in the constructor of MyService, but what I'd like to do is have them all injected as part of a collection.
I can think of a few ways to do this:
Using a facility
Using a component property
Registering the collection as a service
But all of them feel a bit... icky. What's the best way to manage this? Also, ideally I'd like to do this using the fluent API and constructor injection. I know it's possible to do something similar using properties:
http://www.castleproject.org/container/documentation/trunk/usersguide/arrayslistsanddicts.html