private static ParseAttributeUsageAttribute ( |
||
ca | ||
targets | AttributeTargets | |
inherited | bool | |
allowMultiple | bool | |
return | void |
internal static AttributeUsageAttribute GetAttributeUsage(RuntimeType decoratedAttribute) { RuntimeModule runtimeModule = decoratedAttribute.GetRuntimeModule(); MetadataImport metadataImport = runtimeModule.MetadataImport; CustomAttributeRecord[] customAttributeRecords = CustomAttributeData.GetCustomAttributeRecords(runtimeModule, decoratedAttribute.MetadataToken); AttributeUsageAttribute attributeUsageAttribute = null; foreach (CustomAttributeRecord customAttributeRecord in customAttributeRecords) { RuntimeType runtimeType = runtimeModule.ResolveType(metadataImport.GetParentToken(customAttributeRecord.tkCtor), null, null) as RuntimeType; if (!(runtimeType != (RuntimeType)typeof(AttributeUsageAttribute))) { if (attributeUsageAttribute != null) { throw new FormatException(string.Format(CultureInfo.CurrentUICulture, Environment.GetResourceString("Format_AttributeUsage"), runtimeType)); } AttributeTargets validOn; bool inherited; bool allowMultiple; CustomAttribute.ParseAttributeUsageAttribute(customAttributeRecord.blob, out validOn, out inherited, out allowMultiple); attributeUsageAttribute = new AttributeUsageAttribute(validOn, allowMultiple, inherited); } } if (attributeUsageAttribute == null) { return(AttributeUsageAttribute.Default); } return(attributeUsageAttribute); }