in src/Microsoft.NET.Sdk.Functions.Generator/TypeUtility.cs [65:102]
internal static Attribute GetResolvedAttribute(ParameterDefinition parameter, CustomAttribute customAttribute)
{
Attribute attribute = customAttribute.ToReflection();
if (attribute != null &&
attribute.GetType().GetTypeInfo().IsImplementing("IConnectionProvider") &&
string.IsNullOrEmpty(attribute.GetValue<string>("Connection")))
{
// if the attribute doesn't specify an explicit connection, walk up
// the hierarchy looking for an override specified via attribute
var connectionProviderAttribute = attribute
.GetType()
.GetTypeInfo()
.GetCustomAttributes()
.FirstOrDefault(a => a.GetType().Name == "ConnectionProviderAttribute");
if (connectionProviderAttribute?.GetValue<Type>("ProviderType") != null)
{
var connectionOverrideProvider = GetHierarchicalAttributeOrNull(parameter, connectionProviderAttribute.GetValue<Type>("ProviderType"))?.ToReflection();
if (connectionOverrideProvider != null &&
connectionOverrideProvider.GetType().GetTypeInfo().IsImplementing("IConnectionProvider"))
{
var iConnectionProvider = connectionOverrideProvider.GetType().GetTypeInfo().GetInterface("IConnectionProvider");
var propertyInfo = iConnectionProvider.GetProperty("Connection");
var connectionValue = (string)propertyInfo.GetValue(attribute);
connectionValue = connectionValue
?? connectionOverrideProvider.GetValue<string>("Connection")
?? connectionOverrideProvider.GetValue<string>("Account");
if (!string.IsNullOrEmpty(connectionValue))
{
attribute.SetValue("Connection", connectionValue);
}
}
}
}
return attribute;
}