Can Windsor inject lists of components?
Asked Answered
M

1

6

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?

Mckenzie answered 20/4, 2010 at 6:5 Comment(0)
T
8

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

container.Kernel.Resolver.AddSubResolver(new ListResolver(container.Kernel));
Tantalize answered 20/4, 2010 at 10:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.