internal static AttributeUsageAttribute GetAttributeUsage(RuntimeType decoratedAttribute)
{
Module decoratedModule = decoratedAttribute.Module;
MetadataImport scope = decoratedModule.MetadataImport;
CustomAttributeRecord[] car = CustomAttributeData.GetCustomAttributeRecords(decoratedModule, decoratedAttribute.MetadataToken);
AttributeUsageAttribute attributeUsageAttribute = null;
for (int i = 0; i < car.Length; i++)
{
CustomAttributeRecord caRecord = car[i];
RuntimeType attributeType = decoratedModule.ResolveType(scope.GetParentToken(caRecord.tkCtor), null, null) as RuntimeType;
if (attributeType != typeof(AttributeUsageAttribute))
continue;
if (attributeUsageAttribute != null)
throw new FormatException(String.Format(
CultureInfo.CurrentUICulture, Environment.GetResourceString("Format_AttributeUsage"), attributeType));
AttributeTargets targets;
bool inherited, allowMultiple;
ParseAttributeUsageAttribute(caRecord.blob, out targets, out inherited, out allowMultiple);
attributeUsageAttribute = new AttributeUsageAttribute(targets, allowMultiple, inherited);
}
if (attributeUsageAttribute == null)
return AttributeUsageAttribute.Default;
return attributeUsageAttribute;
}
#endregion