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

◆ GetCustomAttributeHelper()

static Attribute System.Diagnostics.Tracing.EventSource.GetCustomAttributeHelper ( MemberInfo member,
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.PublicProperties)] Type attributeType,
EventManifestOptions flags = EventManifestOptions::None )
inlinestaticpackageinherited

Definition at line 2097 of file EventSource.cs.

2098 {
2099 if (!member.Module.Assembly.ReflectionOnly && (flags & EventManifestOptions.AllowEventSourceOverride) == 0)
2100 {
2101 return member.GetCustomAttribute(attributeType, inherit: false);
2102 }
2104 {
2105 if (!AttributeTypeNamesMatch(attributeType, customAttribute.Constructor.ReflectedType))
2106 {
2107 continue;
2108 }
2109 Attribute attribute = null;
2110 if (customAttribute.ConstructorArguments.Count == 1)
2111 {
2112 attribute = (Attribute)Activator.CreateInstance(attributeType, customAttribute.ConstructorArguments[0].Value);
2113 }
2114 else if (customAttribute.ConstructorArguments.Count == 0)
2115 {
2116 attribute = (Attribute)Activator.CreateInstance(attributeType);
2117 }
2118 if (attribute == null)
2119 {
2120 continue;
2121 }
2123 {
2124 PropertyInfo property = attributeType.GetProperty(namedArgument.MemberInfo.Name, BindingFlags.Instance | BindingFlags.Public);
2125 object obj = namedArgument.TypedValue.Value;
2126 if (property.PropertyType.IsEnum)
2127 {
2128 string value = obj.ToString();
2129 obj = Enum.Parse(property.PropertyType, value);
2130 }
2131 property.SetValue(attribute, obj, null);
2132 }
2133 return attribute;
2134 }
2135 return null;
2136 }
static bool AttributeTypeNamesMatch(Type attributeType, Type reflectedAttributeType)
static IList< CustomAttributeData > GetCustomAttributes(MemberInfo target)

References System.Diagnostics.Tracing.EventSource.AttributeTypeNamesMatch(), System.Collections.Generic.Dictionary< TKey, TValue >.Count, System.Activator.CreateInstance(), System.Reflection.CustomAttributeData.GetCustomAttributes(), System.Reflection.MemberInfo.Module, System.obj, System.Enum.Parse(), and System.value.

Referenced by System.Diagnostics.Tracing.EventSource.CreateManifestAndDescriptors(), System.Diagnostics.Tracing.EventSource.GetGuid(), and System.Diagnostics.Tracing.EventSource.GetName().