internal static unsafe void AssignAssociates(AssociateRecord* associates, int cAssociates, RuntimeTypeHandle declaringTypeHandle, RuntimeTypeHandle reflectedTypeHandle, 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 info2; RuntimeMethodInfo info3; RuntimeMethodInfo info4; setter = (RuntimeMethodInfo) (info2 = null); getter = info3 = info2; fireOn = info4 = info3; addOn = removeOn = info4; other = null; Attributes attributes = Attributes.ComposedOfNoStaticMembers | Attributes.ComposedOfNoPublicMembers | Attributes.ComposedOfAllPrivateMethods | Attributes.ComposedOfAllVirtualMethods; while (reflectedTypeHandle.IsGenericVariable()) { reflectedTypeHandle = reflectedTypeHandle.GetRuntimeType().BaseType.GetTypeHandleInternal(); } bool isInherited = !declaringTypeHandle.Equals(reflectedTypeHandle); ArrayList list = new ArrayList(); for (int i = 0; i < cAssociates; i++) { RuntimeMethodInfo info = AssignAssociates(associates[i].MethodDefToken, declaringTypeHandle, reflectedTypeHandle); if (info != null) { MethodAttributes attributes2 = info.Attributes; bool flag2 = (attributes2 & MethodAttributes.MemberAccessMask) == MethodAttributes.Private; bool flag3 = (attributes2 & MethodAttributes.Virtual) != MethodAttributes.PrivateScope; MethodAttributes attributes3 = attributes2 & MethodAttributes.MemberAccessMask; bool flag4 = attributes3 == MethodAttributes.Public; bool flag5 = (attributes2 & MethodAttributes.Static) != MethodAttributes.PrivateScope; if (flag4) { attributes &= ~Attributes.ComposedOfNoPublicMembers; attributes &= ~Attributes.ComposedOfAllPrivateMethods; } else if (!flag2) { attributes &= ~Attributes.ComposedOfAllPrivateMethods; } if (flag5) { attributes &= ~Attributes.ComposedOfNoStaticMembers; } if (!flag3) { attributes &= ~Attributes.ComposedOfAllVirtualMethods; } if (associates[i].Semantics == MethodSemanticsAttributes.Setter) { setter = info; } else if (associates[i].Semantics == MethodSemanticsAttributes.Getter) { getter = info; } else if (associates[i].Semantics == MethodSemanticsAttributes.Fire) { fireOn = info; } else if (associates[i].Semantics == MethodSemanticsAttributes.AddOn) { addOn = info; } else if (associates[i].Semantics == MethodSemanticsAttributes.RemoveOn) { removeOn = info; } else { list.Add(info); } } } bool isPublic = (attributes & Attributes.ComposedOfNoPublicMembers) == 0; bool isStatic = (attributes & Attributes.ComposedOfNoStaticMembers) == 0; bindingFlags = RuntimeType.FilterPreCalculate(isPublic, isInherited, isStatic); composedOfAllPrivateMethods = (attributes & Attributes.ComposedOfAllPrivateMethods) != 0; other = (MethodInfo[]) list.ToArray(typeof(MethodInfo)); }
[System.Security.SecurityCritical] // auto-generated internal static unsafe void AssignAssociates( AssociateRecord* associates, int cAssociates, 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; other = 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 = new List<MethodInfo>(cAssociates); for (int i = 0; i < cAssociates; i++) { #region Assign each associate RuntimeMethodInfo associateMethod = AssignAssociates(associates[i].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 (associates[i].Semantics == MethodSemanticsAttributes.Setter) setter = associateMethod; else if (associates[i].Semantics == MethodSemanticsAttributes.Getter) getter = associateMethod; else if (associates[i].Semantics == MethodSemanticsAttributes.Fire) fireOn = associateMethod; else if (associates[i].Semantics == MethodSemanticsAttributes.AddOn) addOn = associateMethod; else if (associates[i].Semantics == MethodSemanticsAttributes.RemoveOn) removeOn = associateMethod; else 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(); }
public unsafe void GetAssociates(int mdPropEvent, AssociateRecord* result, int count) { int* numPtr = stackalloc int[count * 2]; this.Enum(0x6000000, mdPropEvent, numPtr, count); for (int i = 0; i < count; i++) { result[i].MethodDefToken = numPtr[i * 2]; result[i].Semantics = *((MethodSemanticsAttributes*) (numPtr + ((i * 2) + 1))); } }
public unsafe void GetAssociates(int mdPropEvent, AssociateRecord* result, int count) { int* temp = stackalloc int[count*2]; Enum((int)MetadataTokenType.MethodDef, mdPropEvent, temp, count); for (int i = 0; i < count; i++) { result[i].MethodDefToken = temp[i*2]; result[i].Semantics = (MethodSemanticsAttributes)temp[i * 2 + 1]; } }