Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ GetAttributeUsage()

static AttributeUsageAttribute System.Reflection.CustomAttribute.GetAttributeUsage ( RuntimeType decoratedAttribute)
inlinestaticpackage

Definition at line 477 of file CustomAttribute.cs.

478 {
479 RuntimeModule runtimeModule = decoratedAttribute.GetRuntimeModule();
480 MetadataImport metadataImport = runtimeModule.MetadataImport;
481 CustomAttributeRecord[] customAttributeRecords = RuntimeCustomAttributeData.GetCustomAttributeRecords(runtimeModule, decoratedAttribute.MetadataToken);
482 AttributeUsageAttribute attributeUsageAttribute = null;
483 for (int i = 0; i < customAttributeRecords.Length; i++)
484 {
485 ref CustomAttributeRecord reference = ref customAttributeRecords[i];
486 RuntimeType runtimeType = runtimeModule.ResolveType(metadataImport.GetParentToken(reference.tkCtor), null, null) as RuntimeType;
487 if (!(runtimeType != (RuntimeType)typeof(AttributeUsageAttribute)))
488 {
489 if (attributeUsageAttribute != null)
490 {
491 throw new FormatException(SR.Format(SR.Format_AttributeUsage, runtimeType));
492 }
493 ParseAttributeUsageAttribute(reference.blob, out var targets, out var inherited, out var allowMultiple);
494 attributeUsageAttribute = new AttributeUsageAttribute(targets, allowMultiple, inherited);
495 }
496 }
497 return attributeUsageAttribute ?? AttributeUsageAttribute.Default;
498 }
static void ParseAttributeUsageAttribute(ConstArray ca, out AttributeTargets targets, out bool inherited, out bool allowMultiple)

References System.AttributeUsageAttribute.Default, System.SR.Format(), System.SR.Format_AttributeUsage, System.Reflection.RuntimeCustomAttributeData.GetCustomAttributeRecords(), System.Reflection.MetadataImport.GetParentToken(), System.RuntimeType.GetRuntimeModule(), System.Reflection.RuntimeModule.MetadataImport, System.RuntimeType.MetadataToken, and System.Reflection.RuntimeModule.ResolveType().

Referenced by System.Reflection.CustomAttribute.GetCustomAttributes(), and System.Reflection.CustomAttribute.GetCustomAttributes().