Profile picture Schedule a Meeting
c a n d l a n d . n e t

Resolve Lists and Arrays with Castle Windsor

Dusty Candland | |

I’ve worked with the Castle Project for a long time, primarily with Windsor. However, I often forget there are Array and List dependencies resolvers build-in, but they need to be wired up. This is mostly for my memory and hopefully it helps someone else.

This sub resolvers are in this namespace;

using Castle.MicroKernel.Resolvers.SpecializedResolvers;

Before registering components, add the sub resolvers;

container.Kernel.Resolver.AddSubResolver(new ArrayResolver(container.Kernel));

container.Kernel.Resolver.AddSubResolver(new ListResolver(container.Kernel));

Use like this, where there are multiple IService implementations that are needed by the DependsOnArrayOrList class.

public class DependsOnArrayOrList { public DependsOnArrayOrList(IService[] services) { }

public DependsOnArrayOrList(IList services) { } }

public interface IService { }

Not sure why these sub resolvers are not setup by default, but regardless they’re easy to setup and come in handy.

Webmentions

These are webmentions via the IndieWeb and webmention.io. Mention this post from your site: