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

◆ GetCustomAttributes() [5/10]

static object[] System.Reflection.CustomAttribute.GetCustomAttributes ( RuntimeMethodInfo method,
RuntimeType caType,
bool inherit )
inlinestaticpackage

Definition at line 158 of file CustomAttribute.cs.

159 {
160 if (method.IsGenericMethod && !method.IsGenericMethodDefinition)
161 {
162 method = method.GetGenericMethodDefinition() as RuntimeMethodInfo;
163 }
164 RuntimeType.ListBuilder<Attribute> pcas = default(RuntimeType.ListBuilder<Attribute>);
165 PseudoCustomAttribute.GetCustomAttributes(method, caType, ref pcas);
166 if (!inherit || (caType.IsSealed && !GetAttributeUsage(caType).Inherited))
167 {
168 object[] customAttributes = GetCustomAttributes(method.GetRuntimeModule(), method.MetadataToken, pcas.Count, caType);
169 if (pcas.Count > 0)
170 {
171 pcas.CopyTo(customAttributes, customAttributes.Length - pcas.Count);
172 }
173 return customAttributes;
174 }
175 RuntimeType.ListBuilder<object> attributes = default(RuntimeType.ListBuilder<object>);
176 bool mustBeInheritable = false;
177 RuntimeType elementType = ((caType.IsValueType || caType.ContainsGenericParameters) ? ((RuntimeType)typeof(object)) : caType);
178 for (int i = 0; i < pcas.Count; i++)
179 {
180 attributes.Add(pcas[i]);
181 }
182 while (method != null)
183 {
184 AddCustomAttributes(ref attributes, method.GetRuntimeModule(), method.MetadataToken, caType, mustBeInheritable, attributes);
185 mustBeInheritable = true;
186 method = method.GetParentDefinition();
187 }
188 object[] array = CreateAttributeArrayHelper(elementType, attributes.Count);
189 for (int j = 0; j < attributes.Count; j++)
190 {
191 array[j] = attributes[j];
192 }
193 return array;
194 }
static object[] GetCustomAttributes(RuntimeType type, RuntimeType caType, bool inherit)
static object[] CreateAttributeArrayHelper(RuntimeType elementType, int elementCount)
static unsafe void AddCustomAttributes(ref RuntimeType.ListBuilder< object > attributes, RuntimeModule decoratedModule, int decoratedMetadataToken, RuntimeType attributeFilterType, bool mustBeInheritable, RuntimeType.ListBuilder< object > derivedAttributes)
static AttributeUsageAttribute GetAttributeUsage(RuntimeType decoratedAttribute)

References System.Reflection.CustomAttribute.AddCustomAttributes(), System.array, System.RuntimeType.ContainsGenericParameters, System.Reflection.CustomAttribute.CreateAttributeArrayHelper(), System.elementType, System.Reflection.CustomAttribute.GetAttributeUsage(), System.Reflection.CustomAttribute.GetCustomAttributes(), System.Reflection.PseudoCustomAttribute.GetCustomAttributes(), System.Reflection.RuntimeMethodInfo.GetGenericMethodDefinition(), System.Reflection.RuntimeMethodInfo.GetParentDefinition(), System.Reflection.RuntimeMethodInfo.GetRuntimeModule(), System.Reflection.RuntimeMethodInfo.IsGenericMethod, System.Reflection.RuntimeMethodInfo.IsGenericMethodDefinition, System.Type.IsSealed, and System.Reflection.RuntimeMethodInfo.MetadataToken.