public unsafe void GetAssociates(int mdPropEvent, AssociateRecord *result, int count) { int *numPtr = (int *)stackalloc byte[(((IntPtr)(count * 2)) * 4)]; 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]; } }
internal unsafe RuntimePropertyInfo(int tkProperty, RuntimeType declaredType, RuntimeType.RuntimeTypeCache reflectedTypeCache, out bool isPrivate) { RuntimeMethodInfo info; MetadataImport metadataImport = declaredType.GetRuntimeModule().MetadataImport; this.m_token = tkProperty; this.m_reflectedTypeCache = reflectedTypeCache; this.m_declaringType = declaredType; metadataImport.GetPropertyProps(tkProperty, out this.m_utf8name, out this.m_flags, out MetadataArgs.Skip.ConstArray); int associatesCount = metadataImport.GetAssociatesCount(tkProperty); AssociateRecord *result = (AssociateRecord *)stackalloc byte[(((IntPtr)associatesCount) * sizeof(AssociateRecord))]; metadataImport.GetAssociates(tkProperty, result, associatesCount); Associates.AssignAssociates(result, associatesCount, declaredType, reflectedTypeCache.RuntimeType, out info, out info, out info, out this.m_getterMethod, out this.m_setterMethod, out this.m_otherMethod, out isPrivate, out this.m_bindingFlags); }
internal unsafe RuntimeEventInfo(int tkEvent, RuntimeType declaredType, RuntimeType.RuntimeTypeCache reflectedTypeCache, out bool isPrivate) { RuntimeMethodInfo info; MetadataImport metadataImport = declaredType.GetRuntimeModule().MetadataImport; this.m_token = tkEvent; this.m_reflectedTypeCache = reflectedTypeCache; this.m_declaringType = declaredType; RuntimeType runtimeType = reflectedTypeCache.RuntimeType; metadataImport.GetEventProps(tkEvent, out this.m_utf8name, out this.m_flags); int associatesCount = metadataImport.GetAssociatesCount(tkEvent); AssociateRecord *result = (AssociateRecord *)stackalloc byte[(((IntPtr)associatesCount) * sizeof(AssociateRecord))]; metadataImport.GetAssociates(tkEvent, result, associatesCount); Associates.AssignAssociates(result, associatesCount, declaredType, runtimeType, out this.m_addMethod, out this.m_removeMethod, out this.m_raiseMethod, out info, out info, out this.m_otherMethod, out isPrivate, out this.m_bindingFlags); }
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)); }