private static void ConfigureConstructorAttributes(ConstructorInfo constructorInfo, ref List <Tuple <object, List <Attribute> > > configuredMembers, Action <ParameterInfo, ImportConventionBuilder> configureConstuctorImports)
{
if (configuredMembers == null)
{
configuredMembers = new List <Tuple <object, List <Attribute> > >();
}
// Make its attribute
configuredMembers.Add(Tuple.Create((object)constructorInfo, s_importingConstructorList));
//Okay we have the constructor now we can configure the ImportBuilders
ParameterInfo[] parameterInfos = constructorInfo.GetParameters();
foreach (ParameterInfo pi in parameterInfos)
{
bool isConfigured = pi.GetCustomAttributes <ImportAttribute>(false).FirstOrDefault() != null || pi.GetCustomAttributes <ImportManyAttribute>(false).FirstOrDefault() != null;
if (isConfigured)
{
CompositionTrace.Registration_ParameterImportConventionOverridden(pi, constructorInfo);
}
else
{
var importBuilder = new ImportConventionBuilder();
// Let the developer alter them if they specified to do so
configureConstuctorImports?.Invoke(pi, importBuilder);
// Generate the attributes
List <Attribute> attributes = null;
importBuilder.BuildAttributes(pi.ParameterType, ref attributes);
configuredMembers.Add(Tuple.Create((object)pi, attributes));
}
}
}