AssignAssociates() static private method

static private AssignAssociates ( int tkMethod, RuntimeTypeHandle declaredTypeHandle, RuntimeTypeHandle reflectedTypeHandle ) : RuntimeMethodInfo
tkMethod int
declaredTypeHandle System.RuntimeTypeHandle
reflectedTypeHandle System.RuntimeTypeHandle
return RuntimeMethodInfo
Esempio n. 1
0
        internal RuntimePropertyInfo(
            int tkProperty,
            RuntimeType declaredType,
            RuntimeTypeCache reflectedTypeCache,
            out bool isPrivate
            )
        {
            Debug.Assert(declaredType != null);
            Debug.Assert(reflectedTypeCache != null);
            Debug.Assert(!reflectedTypeCache.IsGlobal);

            MetadataImport scope = declaredType.GetRuntimeModule().MetadataImport;

            m_token = tkProperty;
            m_reflectedTypeCache = reflectedTypeCache;
            m_declaringType      = declaredType;

            scope.GetPropertyProps(tkProperty, out m_utf8name, out m_flags, out _);

            Associates.AssignAssociates(
                scope,
                tkProperty,
                declaredType,
                reflectedTypeCache.GetRuntimeType(),
                out _,
                out _,
                out _,
                out m_getterMethod,
                out m_setterMethod,
                out m_otherMethod,
                out isPrivate,
                out m_bindingFlags
                );
        }
Esempio n. 2
0
        internal RuntimeEventInfo(int tkEvent, RuntimeType declaredType, RuntimeType.RuntimeTypeCache reflectedTypeCache, out bool isPrivate)
        {
            MetadataImport metadataImport = declaredType.GetRuntimeModule().MetadataImport;

            this.m_token = tkEvent;
            this.m_reflectedTypeCache = reflectedTypeCache;
            this.m_declaringType      = declaredType;
            RuntimeType runtimeType = reflectedTypeCache.GetRuntimeType();

            metadataImport.GetEventProps(tkEvent, out this.m_utf8name, out this.m_flags);
            RuntimeMethodInfo runtimeMethodInfo;

            Associates.AssignAssociates(metadataImport, tkEvent, declaredType, runtimeType, out this.m_addMethod, out this.m_removeMethod, out this.m_raiseMethod, out runtimeMethodInfo, out runtimeMethodInfo, out this.m_otherMethod, out isPrivate, out this.m_bindingFlags);
        }
        internal RuntimePropertyInfo(int tkProperty, RuntimeType declaredType, RuntimeType.RuntimeTypeCache reflectedTypeCache, out bool isPrivate)
        {
            MetadataImport metadataImport = declaredType.GetRuntimeModule().MetadataImport;

            this.m_token = tkProperty;
            this.m_reflectedTypeCache = reflectedTypeCache;
            this.m_declaringType      = declaredType;
            ConstArray constArray;

            metadataImport.GetPropertyProps(tkProperty, out this.m_utf8name, out this.m_flags, out constArray);
            RuntimeMethodInfo runtimeMethodInfo;

            Associates.AssignAssociates(metadataImport, tkProperty, declaredType, reflectedTypeCache.GetRuntimeType(), out runtimeMethodInfo, out runtimeMethodInfo, out runtimeMethodInfo, out this.m_getterMethod, out this.m_setterMethod, out this.m_otherMethod, out isPrivate, out this.m_bindingFlags);
        }
        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);
        }
Esempio n. 6
0
        internal RuntimeEventInfo(int tkEvent, RuntimeType declaredType, RuntimeTypeCache reflectedTypeCache, out bool isPrivate)
        {
            Debug.Assert(declaredType != null);
            Debug.Assert(reflectedTypeCache != null);
            Debug.Assert(!reflectedTypeCache.IsGlobal);

            MetadataImport scope = declaredType.GetRuntimeModule().MetadataImport;

            m_token = tkEvent;
            m_reflectedTypeCache = reflectedTypeCache;
            m_declaringType      = declaredType;


            RuntimeType reflectedType = reflectedTypeCache.GetRuntimeType();

            scope.GetEventProps(tkEvent, out m_utf8name, out m_flags);

            Associates.AssignAssociates(scope, tkEvent, declaredType, reflectedType,
                                        out m_addMethod, out m_removeMethod, out m_raiseMethod,
                                        out _, out _, out m_otherMethod, out isPrivate, out m_bindingFlags);
        }
Esempio n. 7
0
        internal unsafe RuntimeEventInfo(int tkEvent, RuntimeType declaredType, RuntimeType.RuntimeTypeCache reflectedTypeCache, out bool isPrivate)
        {
            MetadataImport metadataImport = declaredType.GetRuntimeModule().MetadataImport;

            this.m_token = tkEvent;
            this.m_reflectedTypeCache = reflectedTypeCache;
            this.m_declaringType      = declaredType;
            RuntimeType runtimeType = reflectedTypeCache.GetRuntimeType();

            metadataImport.GetEventProps(tkEvent, out this.m_utf8name, out this.m_flags);
            MetadataImport scope         = metadataImport;
            int            mdPropEvent   = tkEvent;
            RuntimeType    declaringType = declaredType;
            RuntimeType    reflectedType = runtimeType;
            // ISSUE: explicit reference operation
            // ISSUE: variable of a reference type
            RuntimeMethodInfo& addOn = @this.m_addMethod;
            // ISSUE: explicit reference operation
            // ISSUE: variable of a reference type
            RuntimeMethodInfo& removeOn = @this.m_removeMethod;
            // ISSUE: explicit reference operation
            // ISSUE: variable of a reference type
            RuntimeMethodInfo& fireOn = @this.m_raiseMethod;
            RuntimeMethodInfo  runtimeMethodInfo;
            // ISSUE: explicit reference operation
            // ISSUE: variable of a reference type
            RuntimeMethodInfo& local = @runtimeMethodInfo;

            // ISSUE: explicit reference operation
            // ISSUE: variable of a reference type
            MethodInfo[]& other = @this.m_otherMethod;
            // ISSUE: explicit reference operation
            // ISSUE: variable of a reference type
            bool& composedOfAllPrivateMethods = @isPrivate;
            // ISSUE: explicit reference operation
            // ISSUE: variable of a reference type
            BindingFlags& bindingFlags = @this.m_bindingFlags;

            Associates.AssignAssociates(scope, mdPropEvent, declaringType, reflectedType, addOn, removeOn, fireOn, local, local, other, composedOfAllPrivateMethods, bindingFlags);
        }
Esempio n. 8
0
        internal unsafe RuntimePropertyInfo(int tkProperty, RuntimeType declaredType, RuntimeType.RuntimeTypeCache reflectedTypeCache, out bool isPrivate)
        {
            MetadataImport metadataImport = declaredType.GetRuntimeModule().MetadataImport;

            this.m_token = tkProperty;
            this.m_reflectedTypeCache = reflectedTypeCache;
            this.m_declaringType      = declaredType;
            ConstArray signature;

            metadataImport.GetPropertyProps(tkProperty, out this.m_utf8name, out this.m_flags, out signature);
            MetadataImport    scope         = metadataImport;
            int               mdPropEvent   = tkProperty;
            RuntimeType       declaringType = declaredType;
            RuntimeType       runtimeType   = reflectedTypeCache.GetRuntimeType();
            RuntimeMethodInfo runtimeMethodInfo;
            // ISSUE: explicit reference operation
            // ISSUE: variable of a reference type
            RuntimeMethodInfo& local = @runtimeMethodInfo;
            // ISSUE: explicit reference operation
            // ISSUE: variable of a reference type
            RuntimeMethodInfo& getter = @this.m_getterMethod;
            // ISSUE: explicit reference operation
            // ISSUE: variable of a reference type
            RuntimeMethodInfo& setter = @this.m_setterMethod;

            // ISSUE: explicit reference operation
            // ISSUE: variable of a reference type
            MethodInfo[]& other = @this.m_otherMethod;
            // ISSUE: explicit reference operation
            // ISSUE: variable of a reference type
            bool& composedOfAllPrivateMethods = @isPrivate;
            // ISSUE: explicit reference operation
            // ISSUE: variable of a reference type
            BindingFlags& bindingFlags = @this.m_bindingFlags;

            Associates.AssignAssociates(scope, mdPropEvent, declaringType, runtimeType, local, local, local, getter, setter, other, composedOfAllPrivateMethods, bindingFlags);
        }
Esempio n. 9
0
        [System.Security.SecurityCritical]  // auto-generated
        internal RuntimePropertyInfo(
            int tkProperty, RuntimeType declaredType, RuntimeTypeCache reflectedTypeCache, out bool isPrivate)
        {
            Contract.Requires(declaredType != null);
            Contract.Requires(reflectedTypeCache != null);
            Contract.Assert(!reflectedTypeCache.IsGlobal);

            MetadataImport scope = declaredType.GetRuntimeModule().MetadataImport;

            m_token = tkProperty;
            m_reflectedTypeCache = reflectedTypeCache;
            m_declaringType      = declaredType;

            ConstArray sig;

            scope.GetPropertyProps(tkProperty, out m_utf8name, out m_flags, out sig);

            RuntimeMethodInfo dummy;

            Associates.AssignAssociates(scope, tkProperty, declaredType, reflectedTypeCache.GetRuntimeType(),
                                        out dummy, out dummy, out dummy,
                                        out m_getterMethod, out m_setterMethod, out m_otherMethod,
                                        out isPrivate, out m_bindingFlags);
        }
        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);
        }
Esempio n. 11
0
        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;
        }