internal int GetGenericVariableIndex() { RuntimeType typeChecked = this.GetTypeChecked(); if (!RuntimeTypeHandle.IsGenericVariable(typeChecked)) { throw new InvalidOperationException(Environment.GetResourceString("Arg_NotGenericParameter")); } return(RuntimeTypeHandle.GetGenericVariableIndex(typeChecked)); }
private RuntimeType?GetBaseType() { if (IsInterface) { return(null); } if (RuntimeTypeHandle.IsGenericVariable(this)) { Type[] constraints = GetGenericParameterConstraints(); RuntimeType baseType = ObjectType; for (int i = 0; i < constraints.Length; i++) { RuntimeType constraint = (RuntimeType)constraints[i]; if (constraint.IsInterface) { continue; } if (constraint.IsGenericParameter) { GenericParameterAttributes special; special = constraint.GenericParameterAttributes & GenericParameterAttributes.SpecialConstraintMask; if ((special & GenericParameterAttributes.ReferenceTypeConstraint) == 0 && (special & GenericParameterAttributes.NotNullableValueTypeConstraint) == 0) { continue; } } baseType = constraint; } if (baseType == ObjectType) { GenericParameterAttributes special; special = GenericParameterAttributes & GenericParameterAttributes.SpecialConstraintMask; if ((special & GenericParameterAttributes.NotNullableValueTypeConstraint) != 0) { baseType = ValueType; } } return(baseType); } return(RuntimeTypeHandle.GetBaseType(this)); }
internal bool IsGenericVariable() { return(RuntimeTypeHandle.IsGenericVariable(this.GetTypeChecked())); }
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)); }
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) { addOn = removeOn = fireOn = getter = setter = null; other = null; Attributes attributes = Attributes.ComposedOfAllPrivateMethods | Attributes.ComposedOfAllVirtualMethods | Attributes.ComposedOfNoPublicMembers | Attributes.ComposedOfNoStaticMembers; while(reflectedTypeHandle.IsGenericVariable()) reflectedTypeHandle = reflectedTypeHandle.GetRuntimeType().BaseType.GetTypeHandleInternal(); bool isInherited = !declaringTypeHandle.Equals(reflectedTypeHandle); ArrayList otherList = new ArrayList(); for (int i = 0; i < cAssociates; i++) { #region Assign each associate RuntimeMethodInfo associateMethod = AssignAssociates(associates[i].MethodDefToken, declaringTypeHandle, reflectedTypeHandle); 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 isNonProtectedInternal = visibility == MethodAttributes.Assembly; 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 = (MethodInfo[])otherList.ToArray(typeof(MethodInfo)); }