internal static bool IsDefined(RuntimeMethodInfo method, RuntimeType caType, bool inherit) { if (PseudoCustomAttribute.IsDefined(method, caType)) { return(true); } if (CustomAttribute.IsCustomAttributeDefined(method.GetRuntimeModule(), method.MetadataToken, caType)) { return(true); } if (!inherit) { return(false); } method = method.GetParentDefinition(); while (method != null) { if (CustomAttribute.IsCustomAttributeDefined(method.GetRuntimeModule(), method.MetadataToken, caType, 0, inherit)) { return(true); } method = method.GetParentDefinition(); } return(false); }
internal static object[] GetCustomAttributes(RuntimeMethodInfo method, RuntimeType caType, bool inherit) { if (method.IsGenericMethod && !method.IsGenericMethodDefinition) { method = method.GetGenericMethodDefinition() as RuntimeMethodInfo; } int count = 0; Attribute[] sourceArray = PseudoCustomAttribute.GetCustomAttributes(method, caType, true, out count); if (!inherit || (caType.IsSealed && !GetAttributeUsage(caType).Inherited)) { object[] objArray = GetCustomAttributes(method.GetRuntimeModule(), method.MetadataToken, count, caType, !AllowCriticalCustomAttributes(method)); if (count > 0) { Array.Copy(sourceArray, 0, objArray, objArray.Length - count, count); } return(objArray); } List <object> derivedAttributes = new List <object>(); bool mustBeInheritable = false; Type elementType = (((caType == null) || caType.IsValueType) || caType.ContainsGenericParameters) ? typeof(object) : caType; while (count > 0) { derivedAttributes.Add(sourceArray[--count]); } while (method != null) { object[] objArray2 = GetCustomAttributes(method.GetRuntimeModule(), method.MetadataToken, 0, caType, mustBeInheritable, derivedAttributes, !AllowCriticalCustomAttributes(method)); mustBeInheritable = true; for (int i = 0; i < objArray2.Length; i++) { derivedAttributes.Add(objArray2[i]); } method = method.GetParentDefinition(); } object[] destinationArray = CreateAttributeArrayHelper(elementType, derivedAttributes.Count); Array.Copy(derivedAttributes.ToArray(), 0, destinationArray, 0, derivedAttributes.Count); return(destinationArray); }
internal static object[] GetCustomAttributes(RuntimeMethodInfo method, RuntimeType caType, bool inherit) { if (method.IsGenericMethod && !method.IsGenericMethodDefinition) { method = (method.GetGenericMethodDefinition() as RuntimeMethodInfo); } int i = 0; Attribute[] customAttributes = PseudoCustomAttribute.GetCustomAttributes(method, caType, true, out i); if (!inherit || (caType.IsSealed && !CustomAttribute.GetAttributeUsage(caType).Inherited)) { object[] customAttributes2 = CustomAttribute.GetCustomAttributes(method.GetRuntimeModule(), method.MetadataToken, i, caType, !CustomAttribute.AllowCriticalCustomAttributes(method)); if (i > 0) { Array.Copy(customAttributes, 0, customAttributes2, customAttributes2.Length - i, i); } return(customAttributes2); } List <object> list = new List <object>(); bool mustBeInheritable = false; Type elementType = (caType == null || caType.IsValueType || caType.ContainsGenericParameters) ? typeof(object) : caType; while (i > 0) { list.Add(customAttributes[--i]); } while (method != null) { object[] customAttributes3 = CustomAttribute.GetCustomAttributes(method.GetRuntimeModule(), method.MetadataToken, 0, caType, mustBeInheritable, list, !CustomAttribute.AllowCriticalCustomAttributes(method)); mustBeInheritable = true; for (int j = 0; j < customAttributes3.Length; j++) { list.Add(customAttributes3[j]); } method = method.GetParentDefinition(); } object[] array = CustomAttribute.CreateAttributeArrayHelper(elementType, list.Count); Array.Copy(list.ToArray(), 0, array, 0, list.Count); return(array); }
internal static object[] GetCustomAttributes(RuntimeMethodInfo method, RuntimeType caType, bool inherit) { if (method.IsGenericMethod && !method.IsGenericMethodDefinition) { method = method.GetGenericMethodDefinition() as RuntimeMethodInfo; } int count = 0; Attribute[] customAttributes1 = PseudoCustomAttribute.GetCustomAttributes(method, caType, true, out count); if (!inherit || caType.IsSealed && !CustomAttribute.GetAttributeUsage(caType).Inherited) { object[] customAttributes2 = CustomAttribute.GetCustomAttributes(method.GetRuntimeModule(), method.MetadataToken, count, caType, !CustomAttribute.AllowCriticalCustomAttributes((MethodBase)method)); if (count > 0) { Array.Copy((Array)customAttributes1, 0, (Array)customAttributes2, customAttributes2.Length - count, count); } return(customAttributes2); } List <object> objectList = new List <object>(); bool mustBeInheritable = false; Type elementType = (caType == (RuntimeType)null || caType.IsValueType ? 1 : (caType.ContainsGenericParameters ? 1 : 0)) != 0 ? typeof(object) : (Type)caType; while (count > 0) { objectList.Add((object)customAttributes1[--count]); } for (; (MethodInfo)method != (MethodInfo)null; method = method.GetParentDefinition()) { object[] customAttributes2 = CustomAttribute.GetCustomAttributes(method.GetRuntimeModule(), method.MetadataToken, 0, caType, mustBeInheritable, (IList)objectList, !CustomAttribute.AllowCriticalCustomAttributes((MethodBase)method)); mustBeInheritable = true; for (int index = 0; index < customAttributes2.Length; ++index) { objectList.Add(customAttributes2[index]); } } object[] attributeArrayHelper = CustomAttribute.CreateAttributeArrayHelper(elementType, objectList.Count); Array.Copy((Array)objectList.ToArray(), 0, (Array)attributeArrayHelper, 0, objectList.Count); return(attributeArrayHelper); }
internal static IList <CustomAttributeData> GetCustomAttributesInternal(RuntimeMethodInfo target) { IList <CustomAttributeData> customAttributes = GetCustomAttributes(target.GetRuntimeModule(), target.MetadataToken); int count = 0; Attribute[] attributeArray = PseudoCustomAttribute.GetCustomAttributes(target, typeof(object) as RuntimeType, true, out count); if (count == 0) { return(customAttributes); } CustomAttributeData[] array = new CustomAttributeData[customAttributes.Count + count]; customAttributes.CopyTo(array, count); for (int i = 0; i < count; i++) { array[i] = new CustomAttributeData(attributeArray[i]); } return(Array.AsReadOnly <CustomAttributeData>(array)); }
// Token: 0x0600471F RID: 18207 RVA: 0x00102024 File Offset: 0x00100224 internal RuntimeModule GetRuntimeModule() { RuntimeMethodInfo runtimeMethodInfo = this.Member as RuntimeMethodInfo; RuntimeConstructorInfo runtimeConstructorInfo = this.Member as RuntimeConstructorInfo; RuntimePropertyInfo runtimePropertyInfo = this.Member as RuntimePropertyInfo; if (runtimeMethodInfo != null) { return(runtimeMethodInfo.GetRuntimeModule()); } if (runtimeConstructorInfo != null) { return(runtimeConstructorInfo.GetRuntimeModule()); } if (runtimePropertyInfo != null) { return(runtimePropertyInfo.GetRuntimeModule()); } return(null); }
internal RuntimeModule GetRuntimeModule() { RuntimeMethodInfo member = this.Member as RuntimeMethodInfo; RuntimeConstructorInfo info2 = this.Member as RuntimeConstructorInfo; RuntimePropertyInfo info3 = this.Member as RuntimePropertyInfo; if (member != null) { return(member.GetRuntimeModule()); } if (info2 != null) { return(info2.GetRuntimeModule()); } if (info3 != null) { return(info3.GetRuntimeModule()); } return(null); }
internal RuntimeModule GetRuntimeModule() { RuntimeMethodInfo method = Member as RuntimeMethodInfo; RuntimeConstructorInfo constructor = Member as RuntimeConstructorInfo; RuntimePropertyInfo property = Member as RuntimePropertyInfo; if (method != null) { return(method.GetRuntimeModule()); } else if (constructor != null) { return(constructor.GetRuntimeModule()); } else if (property != null) { return(property.GetRuntimeModule()); } else { return(null); } }
internal static IList<CustomAttributeData> GetCustomAttributesInternal(RuntimeMethodInfo target) { IList<CustomAttributeData> customAttributes = GetCustomAttributes(target.GetRuntimeModule(), target.MetadataToken); int count = 0; Attribute[] attributeArray = PseudoCustomAttribute.GetCustomAttributes(target, typeof(object) as RuntimeType, true, out count); if (count == 0) { return customAttributes; } CustomAttributeData[] array = new CustomAttributeData[customAttributes.Count + count]; customAttributes.CopyTo(array, count); for (int i = 0; i < count; i++) { array[i] = new CustomAttributeData(attributeArray[i]); } return Array.AsReadOnly<CustomAttributeData>(array); }
[System.Security.SecurityCritical] // auto-generated internal static Object[] GetCustomAttributes(RuntimeMethodInfo method, RuntimeType caType, bool inherit) { Contract.Requires(method != null); Contract.Requires(caType != null); if (method.IsGenericMethod && !method.IsGenericMethodDefinition) method = method.GetGenericMethodDefinition() as RuntimeMethodInfo; int pcaCount = 0; Attribute[] pca = PseudoCustomAttribute.GetCustomAttributes(method, caType, true, out pcaCount); // if we are asked to go up the hierarchy chain we have to do it now and regardless of the // attribute usage for the specific attribute because a derived attribute may override the usage... // ... however if the attribute is sealed we can rely on the attribute usage if (!inherit || (caType.IsSealed && !CustomAttribute.GetAttributeUsage(caType).Inherited)) { object[] attributes = GetCustomAttributes(method.GetRuntimeModule(), method.MetadataToken, pcaCount, caType, !AllowCriticalCustomAttributes(method)); if (pcaCount > 0) Array.Copy(pca, 0, attributes, attributes.Length - pcaCount, pcaCount); return attributes; } List<object> result = new List<object>(); bool mustBeInheritable = false; bool useObjectArray = (caType == null || caType.IsValueType || caType.ContainsGenericParameters); Type arrayType = useObjectArray ? typeof(object) : caType; while (pcaCount > 0) result.Add(pca[--pcaCount]); while (method != null) { object[] attributes = GetCustomAttributes(method.GetRuntimeModule(), method.MetadataToken, 0, caType, mustBeInheritable, result, !AllowCriticalCustomAttributes(method)); mustBeInheritable = true; for (int i = 0; i < attributes.Length; i++) result.Add(attributes[i]); method = method.GetParentDefinition(); } object[] typedResult = CreateAttributeArrayHelper(arrayType, result.Count); Array.Copy(result.ToArray(), 0, typedResult, 0, result.Count); return typedResult; }
[System.Security.SecuritySafeCritical] // auto-generated internal static bool IsDefined(RuntimeMethodInfo method, RuntimeType caType, bool inherit) { Contract.Requires(method != null); Contract.Requires(caType != null); if (PseudoCustomAttribute.IsDefined(method, caType)) return true; if (IsCustomAttributeDefined(method.GetRuntimeModule(), method.MetadataToken, caType)) return true; if (!inherit) return false; method = method.GetParentDefinition(); while (method != null) { if (IsCustomAttributeDefined(method.GetRuntimeModule(), method.MetadataToken, caType, 0, inherit)) return true; method = method.GetParentDefinition(); } return false; }
[System.Security.SecuritySafeCritical] // auto-generated internal static IList<CustomAttributeData> GetCustomAttributesInternal(RuntimeMethodInfo target) { Contract.Assert(target != null); IList<CustomAttributeData> cad = GetCustomAttributes(target.GetRuntimeModule(), target.MetadataToken); int pcaCount = 0; Attribute[] a = PseudoCustomAttribute.GetCustomAttributes((RuntimeMethodInfo)target, typeof(object) as RuntimeType, true, out pcaCount); if (pcaCount == 0) return cad; CustomAttributeData[] pca = new CustomAttributeData[cad.Count + pcaCount]; cad.CopyTo(pca, pcaCount); for (int i = 0; i < pcaCount; i++) { pca[i] = new CustomAttributeData(a[i]); } return Array.AsReadOnly(pca); }
internal static IList <CustomAttributeData> GetCustomAttributesInternal(RuntimeMethodInfo target) { IList <CustomAttributeData> customAttributes1 = CustomAttributeData.GetCustomAttributes(target.GetRuntimeModule(), target.MetadataToken); int count = 0; Attribute[] customAttributes2 = PseudoCustomAttribute.GetCustomAttributes(target, typeof(object) as RuntimeType, true, out count); if (count == 0) { return(customAttributes1); } CustomAttributeData[] array = new CustomAttributeData[customAttributes1.Count + count]; customAttributes1.CopyTo(array, count); for (int index = 0; index < count; ++index) { array[index] = new CustomAttributeData(customAttributes2[index]); } return((IList <CustomAttributeData>)Array.AsReadOnly <CustomAttributeData>(array)); }
[System.Security.SecuritySafeCritical] // auto-generated internal static bool IsDefined(RuntimeMethodInfo method, RuntimeType caType, bool inherit) { Contract.Requires(method != null); Contract.Requires(caType != null); #if !FEATURE_CORECLR if (FrameworkEventSource.IsInitialized && FrameworkEventSource.Log.IsEnabled(EventLevel.Informational, FrameworkEventSource.Keywords.DynamicTypeUsage) && caType != null) { FrameworkEventSource.Log.QueryAttributeIsDefined(caType.GetFullNameForEtw()); } #endif if (PseudoCustomAttribute.IsDefined(method, caType)) return true; if (IsCustomAttributeDefined(method.GetRuntimeModule(), method.MetadataToken, caType)) return true; if (!inherit) return false; method = method.GetParentDefinition(); while (method != null) { if (IsCustomAttributeDefined(method.GetRuntimeModule(), method.MetadataToken, caType, 0, inherit)) return true; method = method.GetParentDefinition(); } return false; }
internal static bool IsDefined(RuntimeMethodInfo method, RuntimeType caType, bool inherit) { if (PseudoCustomAttribute.IsDefined(method, caType)) { return true; } if (IsCustomAttributeDefined(method.GetRuntimeModule(), method.MetadataToken, caType)) { return true; } if (inherit) { method = method.GetParentDefinition(); while (method != null) { if (IsCustomAttributeDefined(method.GetRuntimeModule(), method.MetadataToken, caType, inherit)) { return true; } method = method.GetParentDefinition(); } } return false; }
internal static object[] GetCustomAttributes(RuntimeMethodInfo method, RuntimeType caType, bool inherit) { if (method.IsGenericMethod && !method.IsGenericMethodDefinition) { method = method.GetGenericMethodDefinition() as RuntimeMethodInfo; } int count = 0; Attribute[] sourceArray = PseudoCustomAttribute.GetCustomAttributes(method, caType, true, out count); if (!inherit || (caType.IsSealed && !GetAttributeUsage(caType).Inherited)) { object[] objArray = GetCustomAttributes(method.GetRuntimeModule(), method.MetadataToken, count, caType, !AllowCriticalCustomAttributes(method)); if (count > 0) { Array.Copy(sourceArray, 0, objArray, objArray.Length - count, count); } return objArray; } List<object> derivedAttributes = new List<object>(); bool mustBeInheritable = false; Type elementType = (((caType == null) || caType.IsValueType) || caType.ContainsGenericParameters) ? typeof(object) : caType; while (count > 0) { derivedAttributes.Add(sourceArray[--count]); } while (method != null) { object[] objArray2 = GetCustomAttributes(method.GetRuntimeModule(), method.MetadataToken, 0, caType, mustBeInheritable, derivedAttributes, !AllowCriticalCustomAttributes(method)); mustBeInheritable = true; for (int i = 0; i < objArray2.Length; i++) { derivedAttributes.Add(objArray2[i]); } method = method.GetParentDefinition(); } object[] destinationArray = CreateAttributeArrayHelper(elementType, derivedAttributes.Count); Array.Copy(derivedAttributes.ToArray(), 0, destinationArray, 0, derivedAttributes.Count); return destinationArray; }