Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can Windsor inject lists of components?

Consider this example:

    public class Factory
    {
        private List<ISubFactory> subFactories;

        public Factory(List<ISubFactory> subFactories)
        {
            this.subFactories = subFactories;
        }
    }

    public interface ISubFactory
    {

    }

I want Windsor to resolve the Factory class and put all implementers of the ISubFactory interface which are registered in the container (ResolveAll) into the "subFactories" parameter, can Windsor do this?

like image 660
Marius Avatar asked Apr 20 '10 06:04

Marius


1 Answers

Yes, it can. But you have to opt in first, by registering ListResolver

container.Kernel.Resolver.AddSubResolver(new ListResolver(container.Kernel));
like image 137
Krzysztof Kozmic Avatar answered Oct 23 '22 00:10

Krzysztof Kozmic