public override IDependencyResolverPolicy GetResolver(IBuilderContext context, Type dependencyType) { ConstructorArgumentResolveOperation currentOperation = context.CurrentOperation as ConstructorArgumentResolveOperation; if (currentOperation != null) { var parameter = currentOperation.TypeBeingConstructed.GetConstructors().Single().GetParameters().Single(x => x.Name == currentOperation.ParameterName); if (parameter.ParameterType == _type) { return(_value.GetResolverPolicy(dependencyType)); } } return(null); }
/// <summary> /// A helper method used by the generated IL to store the current operation in the build context. /// </summary> public static void SetCurrentOperationToResolvingParameter(string parameterName, string constructorSignature, IBuilderContext context) { (context ?? throw new ArgumentNullException(nameof(context))).CurrentOperation = new ConstructorArgumentResolveOperation( context.BuildKey.Type, constructorSignature, parameterName); }