I've added the CollectionResolver
as a sub-resolver of my Windsor kernel, and it will properly inject collections of dependencies on resolved objects. That is, if I have
class X { public X(IComponent[] components) { ... } }
container.Register(/* lots of IComponents */);
container.Register(Component.For<X>());
the components
argument to the constructor is properly constructed when I resolve it
container.Resolve<X>()
but if instead I'd just like to get the list of components themselves,
container.Resolve<IComponent[]>()
I get a ComponentNotFound
exception complaining that I have not registered any components for IComponent[]
. I find this asymmetry counterintuitive as I'm not sure why the kernel should act differently when it is resolving dependencies it found on constructors/properties as compared to when it is resolving dependencies its user would like it to resolve.
The explicit division for Resolve
/ResolveAll
is due to internal and uninteresting implementation details in the container. The collection resolver is a sub depenendcy resolver and as such it only works for dependencies.
I agree it is not really intuitive. Feel free to log a ticket into Windsor's issue tracker about it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With