public Enum ( int type, int parent, int result, int count ) : void | ||
type | int | |
parent | int | |
result | int | |
count | int | |
Résultat | void |
public sealed override Type[] GetForwardedTypes() { List <Type> types = new List <Type>(); List <Exception> exceptions = new List <Exception>(); MetadataImport scope = GetManifestModule(GetNativeHandle()).MetadataImport; scope.Enum(MetadataTokenType.ExportedType, 0, out MetadataEnumResult enumResult); RuntimeAssembly runtimeAssembly = this; QCallAssembly pAssembly = new QCallAssembly(ref runtimeAssembly); for (int i = 0; i < enumResult.Length; i++) { MetadataToken mdtExternalType = enumResult[i]; Type? type = null; Exception? exception = null; ObjectHandleOnStack pType = ObjectHandleOnStack.Create(ref type); try { GetForwardedType(pAssembly, mdtExternalType, pType); if (type == null) { continue; // mdtExternalType was not a forwarder entry. } } catch (Exception e) { type = null; exception = e; } Debug.Assert((type != null) != (exception != null)); // Exactly one of these must be non-null. if (type != null) { types.Add(type); AddPublicNestedTypes(type, types, exceptions); } else { exceptions.Add(exception !); } } if (exceptions.Count != 0) { int numTypes = types.Count; int numExceptions = exceptions.Count; types.AddRange(new Type[numExceptions]); // add one null Type for each exception. exceptions.InsertRange(0, new Exception[numTypes]); // align the Exceptions with the null Types. throw new ReflectionTypeLoadException(types.ToArray(), exceptions.ToArray()); } return(types.ToArray()); }
internal static void AssignAssociates( MetadataImport scope, int mdPropEvent, RuntimeType declaringType, RuntimeType reflectedType, out RuntimeMethodInfo?addOn, out RuntimeMethodInfo?removeOn, out RuntimeMethodInfo?fireOn, out RuntimeMethodInfo?getter, out RuntimeMethodInfo?setter, out MethodInfo[]?other, out bool composedOfAllPrivateMethods, out BindingFlags bindingFlags) { addOn = removeOn = fireOn = getter = setter = null; Attributes attributes = Attributes.ComposedOfAllPrivateMethods | Attributes.ComposedOfAllVirtualMethods | Attributes.ComposedOfNoPublicMembers | Attributes.ComposedOfNoStaticMembers; while (RuntimeTypeHandle.IsGenericVariable(reflectedType)) { reflectedType = (RuntimeType)reflectedType.BaseType !; } bool isInherited = declaringType != reflectedType; List <MethodInfo>?otherList = null; scope.Enum(MetadataTokenType.MethodDef, mdPropEvent, out MetadataEnumResult associatesData); int cAssociates = associatesData.Length / 2; for (int i = 0; i < cAssociates; i++) { int methodDefToken = associatesData[i * 2]; MethodSemanticsAttributes semantics = (MethodSemanticsAttributes)associatesData[i * 2 + 1]; #region Assign each associate RuntimeMethodInfo?associateMethod = AssignAssociates(methodDefToken, declaringType, reflectedType); if (associateMethod == null) { continue; } MethodAttributes methAttr = associateMethod.Attributes; bool isPrivate = (methAttr & MethodAttributes.MemberAccessMask) == MethodAttributes.Private; bool isVirtual = (methAttr & MethodAttributes.Virtual) != 0; MethodAttributes visibility = methAttr & MethodAttributes.MemberAccessMask; bool isPublic = visibility == MethodAttributes.Public; bool isStatic = (methAttr & MethodAttributes.Static) != 0; if (isPublic) { attributes &= ~Attributes.ComposedOfNoPublicMembers; attributes &= ~Attributes.ComposedOfAllPrivateMethods; } else if (!isPrivate) { attributes &= ~Attributes.ComposedOfAllPrivateMethods; } if (isStatic) { attributes &= ~Attributes.ComposedOfNoStaticMembers; } if (!isVirtual) { attributes &= ~Attributes.ComposedOfAllVirtualMethods; } #endregion if (semantics == MethodSemanticsAttributes.Setter) { setter = associateMethod; } else if (semantics == MethodSemanticsAttributes.Getter) { getter = associateMethod; } else if (semantics == MethodSemanticsAttributes.Fire) { fireOn = associateMethod; } else if (semantics == MethodSemanticsAttributes.AddOn) { addOn = associateMethod; } else if (semantics == MethodSemanticsAttributes.RemoveOn) { removeOn = associateMethod; } else { otherList ??= new List <MethodInfo>(cAssociates); otherList.Add(associateMethod); } } bool isPseudoPublic = (attributes & Attributes.ComposedOfNoPublicMembers) == 0; bool isPseudoStatic = (attributes & Attributes.ComposedOfNoStaticMembers) == 0; bindingFlags = RuntimeType.FilterPreCalculate(isPseudoPublic, isInherited, isPseudoStatic); composedOfAllPrivateMethods = (attributes & Attributes.ComposedOfAllPrivateMethods) != 0; other = otherList?.ToArray(); }
internal static void AssignAssociates(MetadataImport scope, int mdPropEvent, RuntimeType declaringType, RuntimeType reflectedType, out RuntimeMethodInfo addOn, out RuntimeMethodInfo removeOn, out RuntimeMethodInfo fireOn, out RuntimeMethodInfo getter, out RuntimeMethodInfo setter, out MethodInfo[] other, out bool composedOfAllPrivateMethods, out BindingFlags bindingFlags) { RuntimeMethodInfo runtimeMethodInfo; setter = (runtimeMethodInfo = null); getter = (runtimeMethodInfo = runtimeMethodInfo); fireOn = (runtimeMethodInfo = runtimeMethodInfo); removeOn = (runtimeMethodInfo = runtimeMethodInfo); addOn = runtimeMethodInfo; Associates.Attributes attributes = Associates.Attributes.ComposedOfAllVirtualMethods | Associates.Attributes.ComposedOfAllPrivateMethods | Associates.Attributes.ComposedOfNoPublicMembers | Associates.Attributes.ComposedOfNoStaticMembers; while (RuntimeTypeHandle.IsGenericVariable(reflectedType)) { reflectedType = (RuntimeType)reflectedType.BaseType; } bool isInherited = declaringType != reflectedType; List <MethodInfo> list = null; MetadataEnumResult metadataEnumResult; scope.Enum(MetadataTokenType.MethodDef, mdPropEvent, out metadataEnumResult); int num = metadataEnumResult.Length / 2; for (int i = 0; i < num; i++) { int tkMethod = metadataEnumResult[i * 2]; MethodSemanticsAttributes methodSemanticsAttributes = (MethodSemanticsAttributes)metadataEnumResult[i * 2 + 1]; RuntimeMethodInfo runtimeMethodInfo2 = Associates.AssignAssociates(tkMethod, declaringType, reflectedType); if (!(runtimeMethodInfo2 == null)) { MethodAttributes attributes2 = runtimeMethodInfo2.Attributes; bool flag = (attributes2 & MethodAttributes.MemberAccessMask) == MethodAttributes.Private; bool flag2 = (attributes2 & MethodAttributes.Virtual) > MethodAttributes.PrivateScope; MethodAttributes methodAttributes = attributes2 & MethodAttributes.MemberAccessMask; bool flag3 = methodAttributes == MethodAttributes.Public; bool flag4 = (attributes2 & MethodAttributes.Static) > MethodAttributes.PrivateScope; if (flag3) { attributes &= ~Associates.Attributes.ComposedOfNoPublicMembers; attributes &= ~Associates.Attributes.ComposedOfAllPrivateMethods; } else if (!flag) { attributes &= ~Associates.Attributes.ComposedOfAllPrivateMethods; } if (flag4) { attributes &= ~Associates.Attributes.ComposedOfNoStaticMembers; } if (!flag2) { attributes &= ~Associates.Attributes.ComposedOfAllVirtualMethods; } if (methodSemanticsAttributes == MethodSemanticsAttributes.Setter) { setter = runtimeMethodInfo2; } else if (methodSemanticsAttributes == MethodSemanticsAttributes.Getter) { getter = runtimeMethodInfo2; } else if (methodSemanticsAttributes == MethodSemanticsAttributes.Fire) { fireOn = runtimeMethodInfo2; } else if (methodSemanticsAttributes == MethodSemanticsAttributes.AddOn) { addOn = runtimeMethodInfo2; } else if (methodSemanticsAttributes == MethodSemanticsAttributes.RemoveOn) { removeOn = runtimeMethodInfo2; } else { if (list == null) { list = new List <MethodInfo>(num); } list.Add(runtimeMethodInfo2); } } } bool isPublic = (attributes & Associates.Attributes.ComposedOfNoPublicMembers) == (Associates.Attributes) 0; bool isStatic = (attributes & Associates.Attributes.ComposedOfNoStaticMembers) == (Associates.Attributes) 0; bindingFlags = RuntimeType.FilterPreCalculate(isPublic, isInherited, isStatic); composedOfAllPrivateMethods = ((attributes & Associates.Attributes.ComposedOfAllPrivateMethods) > (Associates.Attributes) 0); other = ((list != null) ? list.ToArray() : null); }
[System.Security.SecurityCritical] // auto-generated internal static unsafe void AssignAssociates( MetadataImport scope, int mdPropEvent, RuntimeType declaringType, RuntimeType reflectedType, out RuntimeMethodInfo addOn, out RuntimeMethodInfo removeOn, out RuntimeMethodInfo fireOn, out RuntimeMethodInfo getter, out RuntimeMethodInfo setter, out MethodInfo[] other, out bool composedOfAllPrivateMethods, out BindingFlags bindingFlags) { addOn = removeOn = fireOn = getter = setter = null; Attributes attributes = Attributes.ComposedOfAllPrivateMethods | Attributes.ComposedOfAllVirtualMethods | Attributes.ComposedOfNoPublicMembers | Attributes.ComposedOfNoStaticMembers; while(RuntimeTypeHandle.IsGenericVariable(reflectedType)) reflectedType = (RuntimeType)reflectedType.BaseType; bool isInherited = declaringType != reflectedType; List<MethodInfo> otherList = null; MetadataEnumResult associatesData; scope.Enum(MetadataTokenType.MethodDef, mdPropEvent, out associatesData); int cAssociates = associatesData.Length / 2; for (int i = 0; i < cAssociates; i++) { int methodDefToken = associatesData[i * 2]; MethodSemanticsAttributes semantics = (MethodSemanticsAttributes)associatesData[i * 2 + 1]; #region Assign each associate RuntimeMethodInfo associateMethod = AssignAssociates(methodDefToken, declaringType, reflectedType); if (associateMethod == null) continue; MethodAttributes methAttr = associateMethod.Attributes; bool isPrivate =(methAttr & MethodAttributes.MemberAccessMask) == MethodAttributes.Private; bool isVirtual =(methAttr & MethodAttributes.Virtual) != 0; MethodAttributes visibility = methAttr & MethodAttributes.MemberAccessMask; bool isPublic = visibility == MethodAttributes.Public; bool isStatic =(methAttr & MethodAttributes.Static) != 0; if (isPublic) { attributes &= ~Attributes.ComposedOfNoPublicMembers; attributes &= ~Attributes.ComposedOfAllPrivateMethods; } else if (!isPrivate) { attributes &= ~Attributes.ComposedOfAllPrivateMethods; } if (isStatic) attributes &= ~Attributes.ComposedOfNoStaticMembers; if (!isVirtual) attributes &= ~Attributes.ComposedOfAllVirtualMethods; #endregion if (semantics == MethodSemanticsAttributes.Setter) setter = associateMethod; else if (semantics == MethodSemanticsAttributes.Getter) getter = associateMethod; else if (semantics == MethodSemanticsAttributes.Fire) fireOn = associateMethod; else if (semantics == MethodSemanticsAttributes.AddOn) addOn = associateMethod; else if (semantics == MethodSemanticsAttributes.RemoveOn) removeOn = associateMethod; else { if (otherList == null) otherList = new List<MethodInfo>(cAssociates); otherList.Add(associateMethod); } } bool isPseudoPublic = (attributes & Attributes.ComposedOfNoPublicMembers) == 0; bool isPseudoStatic = (attributes & Attributes.ComposedOfNoStaticMembers) == 0; bindingFlags = RuntimeType.FilterPreCalculate(isPseudoPublic, isInherited, isPseudoStatic); composedOfAllPrivateMethods =(attributes & Attributes.ComposedOfAllPrivateMethods) != 0; other = (otherList != null) ? otherList.ToArray() : null; }
internal static void AssignAssociates(MetadataImport scope, int mdPropEvent, RuntimeType declaringType, RuntimeType reflectedType, out RuntimeMethodInfo addOn, out RuntimeMethodInfo removeOn, out RuntimeMethodInfo fireOn, out RuntimeMethodInfo getter, out RuntimeMethodInfo setter, out MethodInfo[] other, out bool composedOfAllPrivateMethods, out BindingFlags bindingFlags) { addOn = removeOn = fireOn = getter = setter = (RuntimeMethodInfo)null; Associates.Attributes attributes1 = Associates.Attributes.ComposedOfAllVirtualMethods | Associates.Attributes.ComposedOfAllPrivateMethods | Associates.Attributes.ComposedOfNoPublicMembers | Associates.Attributes.ComposedOfNoStaticMembers; while (RuntimeTypeHandle.IsGenericVariable(reflectedType)) { reflectedType = (RuntimeType)reflectedType.BaseType; } bool isInherited = declaringType != reflectedType; List <MethodInfo> methodInfoList = (List <MethodInfo>)null; MetadataEnumResult result; scope.Enum(MetadataTokenType.MethodDef, mdPropEvent, out result); int capacity = result.Length / 2; for (int index = 0; index < capacity; ++index) { int tkMethod = result[index * 2]; MethodSemanticsAttributes semanticsAttributes = (MethodSemanticsAttributes)result[index * 2 + 1]; RuntimeType declaredType = declaringType; RuntimeType reflectedType1 = reflectedType; RuntimeMethodInfo runtimeMethodInfo = Associates.AssignAssociates(tkMethod, declaredType, reflectedType1); if (!((MethodInfo)runtimeMethodInfo == (MethodInfo)null)) { MethodAttributes attributes2 = runtimeMethodInfo.Attributes; bool flag1 = (attributes2 & MethodAttributes.MemberAccessMask) == MethodAttributes.Private; bool flag2 = (uint)(attributes2 & MethodAttributes.Virtual) > 0U; int num = (attributes2 & MethodAttributes.MemberAccessMask) == MethodAttributes.Public ? 1 : 0; bool flag3 = (uint)(attributes2 & MethodAttributes.Static) > 0U; if (num != 0) { attributes1 = attributes1 & ~Associates.Attributes.ComposedOfNoPublicMembers & ~Associates.Attributes.ComposedOfAllPrivateMethods; } else if (!flag1) { attributes1 &= ~Associates.Attributes.ComposedOfAllPrivateMethods; } if (flag3) { attributes1 &= ~Associates.Attributes.ComposedOfNoStaticMembers; } if (!flag2) { attributes1 &= ~Associates.Attributes.ComposedOfAllVirtualMethods; } if (semanticsAttributes == MethodSemanticsAttributes.Setter) { setter = runtimeMethodInfo; } else if (semanticsAttributes == MethodSemanticsAttributes.Getter) { getter = runtimeMethodInfo; } else if (semanticsAttributes == MethodSemanticsAttributes.Fire) { fireOn = runtimeMethodInfo; } else if (semanticsAttributes == MethodSemanticsAttributes.AddOn) { addOn = runtimeMethodInfo; } else if (semanticsAttributes == MethodSemanticsAttributes.RemoveOn) { removeOn = runtimeMethodInfo; } else { if (methodInfoList == null) { methodInfoList = new List <MethodInfo>(capacity); } methodInfoList.Add((MethodInfo)runtimeMethodInfo); } } } bool isPublic = (attributes1 & Associates.Attributes.ComposedOfNoPublicMembers) == (Associates.Attributes) 0; bool isStatic = (attributes1 & Associates.Attributes.ComposedOfNoStaticMembers) == (Associates.Attributes) 0; bindingFlags = RuntimeType.FilterPreCalculate(isPublic, isInherited, isStatic); composedOfAllPrivateMethods = (uint)(attributes1 & Associates.Attributes.ComposedOfAllPrivateMethods) > 0U; other = methodInfoList != null?methodInfoList.ToArray() : (MethodInfo[])null; }