public SelectedConstructor SelectConstructor(IBuilderContext context) { var target = BuildKey.GetType(context.BuildKey); var typeTracker = context.Policies.Get <TypeTrackerPolicy>(context.BuildKey).TypeTracker; var constructor = SelectConstructor(target, typeTracker); if (constructor == null) { return(null); } // Unity includes a policy used when explicitly configuring injection. Here we borrow // it to specify the constructor we want to user. Normally the user specifies a specific // constructor and the policies for filling its parameters, here we do it automatically. var parameters = new List <InjectionParameterValue>(); foreach (var parameter in constructor.GetParameters()) { parameters.Add(new TypeToBeResolved( parameter.ParameterType, parameterResolver.GetResolver(parameter))); } return(new SpecifiedConstructorSelectorPolicy(constructor, parameters.ToArray()) .SelectConstructor(context)); }