当前位置: 首页>>代码示例>>C#>>正文


C# RuntimeTypeHandle.IsGenericVariable方法代码示例

本文整理汇总了C#中System.RuntimeTypeHandle.IsGenericVariable方法的典型用法代码示例。如果您正苦于以下问题:C# RuntimeTypeHandle.IsGenericVariable方法的具体用法?C# RuntimeTypeHandle.IsGenericVariable怎么用?C# RuntimeTypeHandle.IsGenericVariable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.RuntimeTypeHandle的用法示例。


在下文中一共展示了RuntimeTypeHandle.IsGenericVariable方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AssignAssociates

 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));
 }
开发者ID:randomize,项目名称:VimConfig,代码行数:77,代码来源:Associates.cs

示例2: AssignAssociates

        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));
        }
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:87,代码来源:xxxinfos.cs


注:本文中的System.RuntimeTypeHandle.IsGenericVariable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。