/// <summary> /// Return the sequence of methods to call while building the target object. /// </summary> /// <param name = "context">Current build context.</param> /// <param name = "resolverPolicyDestination">The <see cref = 'IPolicyList' /> to add any /// generated resolver objects into.</param> /// <returns>Sequence of methods to call.</returns> public IEnumerable<SelectedMethod> SelectMethods(IBuilderContext context, IPolicyList resolverPolicyDestination) { foreach (Pair<MethodInfo, IEnumerable<InjectionParameterValue>> method in methods) { Type typeToBuild = context.BuildKey.Type; SelectedMethod selectedMethod; var typeReflector = new ReflectionHelper(method.First.DeclaringType); var methodReflector = new MethodReflectionHelper(method.First); if (!methodReflector.MethodHasOpenGenericParameters && !typeReflector.IsOpenGeneric) { selectedMethod = new SelectedMethod(method.First); } else { Type[] closedMethodParameterTypes = methodReflector.GetClosedParameterTypes(typeToBuild.GetGenericArguments()); selectedMethod = new SelectedMethod( typeToBuild.GetMethod(method.First.Name, closedMethodParameterTypes)); } SpecifiedMemberSelectorHelper.AddParameterResolvers( typeToBuild, resolverPolicyDestination, method.Second, selectedMethod); yield return selectedMethod; } }
public SpecifiedConstructorSelectorPolicy(ConstructorInfo ctor, InjectionParameterValue[] parameterValues) { this.ctor = ctor; ctorReflector = new MethodReflectionHelper(ctor); this.parameterValues = parameterValues; }