Access to ResolverOverrides from BuilderStrategy.PreBuildUp

Aug 25, 2011 at 8:56 AM

Hi,

I am playing with the concept of a strategy that resembles the ArrayResolutionStrategy but works for IEnumerable<T>, IList<T> and ICollection<T>. The concept is rather simple but it gets difficult when I add ResolverOverrides to the picture.

When calling

container.Resolve<IList<IFoo>>(new ParameterOverride("args1","1"));

I want the strategy to perform a ResolveAll() call that uses the specified override. The ArrayResolutionStrategy would just ignore the override and call ResolveAll() without parameters.

IBuilderContext.GetOverridenResolver(Type) returns null for either IFoo or IList<IFoo>. I checked the sources and due to the implementation of ParameterOverride.GetResolver I can only get a meaningful result if I am in a ConstructorArgumentResolutionOperation. Which I am not.

I know that I could access the resolverOverrides field in the BuilderContext class via reflection but that would definitely harm encapsulation and couple my strategy very tightly to the implementation of BuilderContext. Not what I want either.

Any other ideas how I could solve that issue?

Thanks!