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


C# RuntimeTypeHandle.IsNullHandle方法代码示例

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


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

示例1: Emit

     public void Emit(OpCode opcode, RuntimeTypeHandle typeHandle) {   
         if (typeHandle.IsNullHandle()) 
             throw new ArgumentNullException("typeHandle");
 
         int tempVal = m_scope.GetTokenFor(typeHandle);   
         EnsureCapacity(7);
         InternalEmit(opcode);
         m_length=PutInteger4(tempVal, m_length, m_ILStream);
     }
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:9,代码来源:dynamicilgenerator.cs

示例2: Emit

 public void Emit(OpCode opcode, RuntimeMethodHandle meth, RuntimeTypeHandle typeContext)
 {
     if (meth.IsNullHandle())
     {
         throw new ArgumentNullException("meth");
     }
     if (typeContext.IsNullHandle())
     {
         throw new ArgumentNullException("typeContext");
     }
     int tokenFor = this.m_scope.GetTokenFor(meth, typeContext);
     base.EnsureCapacity(7);
     base.InternalEmit(opcode);
     base.UpdateStackSize(opcode, 1);
     base.PutInteger4(tokenFor);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:16,代码来源:DynamicILGenerator.cs

示例3: AssignAssociates

        internal static unsafe RuntimeMethodInfo AssignAssociates(
            int tkMethod,
            RuntimeTypeHandle declaredTypeHandle,
            RuntimeTypeHandle reflectedTypeHandle)
        {
            if (MetadataToken.IsNullToken(tkMethod))
                return null;

            ASSERT.PRECONDITION(!declaredTypeHandle.IsNullHandle());
            ASSERT.PRECONDITION(!reflectedTypeHandle.IsNullHandle());

            bool isInherited = !declaredTypeHandle.Equals(reflectedTypeHandle);

            RuntimeMethodHandle associateMethodHandle = declaredTypeHandle.GetModuleHandle().ResolveMethodHandle(tkMethod, declaredTypeHandle.GetInstantiation(), new RuntimeTypeHandle[0]);
            //RuntimeMethodHandle associateMethodHandle = declaredTypeHandle.GetMethodFromToken(tkMethod);
            ASSERT.CONSISTENCY_CHECK(!associateMethodHandle.IsNullHandle(), "Failed to resolve associateRecord methodDef token");

            MethodAttributes methAttr = associateMethodHandle.GetAttributes();
            bool isPrivate =(methAttr & MethodAttributes.MemberAccessMask) == MethodAttributes.Private;
            bool isVirtual =(methAttr & MethodAttributes.Virtual) != 0;

            if (isInherited)
            {
                // ECMA MethodSemantics: "All methods for a given Property or Event shall have the same accessibility 
                //(ie the MemberAccessMask subfield of their Flags row) and cannot be CompilerControlled  [CLS]"
                // Consequently, a property may be composed of public and private methods. If the declared type !=
                // the reflected type, the private methods should not be exposed. Note that this implies that the 
                // identity of a property includes it's reflected type.
                if (isPrivate)
                    return null;

                // Note this is the first time the property was encountered walking from the most derived class 
                // towards the base class. It would seem to follow that any associated methods would not
                // be overriden -- but this is not necessarily true. A more derived class may have overriden a
                // virtual method associated with a property in a base class without associating the override with 
                // the same or any property in the derived class. 
                if (isVirtual)
                {
                    bool declaringTypeIsClass = 
                        (declaredTypeHandle.GetAttributes() & TypeAttributes.ClassSemanticsMask) == TypeAttributes.Class;

                    ASSERT.CONSISTENCY_CHECK(LOGIC.BIJECTION(declaringTypeIsClass, 
                        (reflectedTypeHandle.GetAttributes() & TypeAttributes.ClassSemanticsMask) == TypeAttributes.Class));

                    // It makes no sense to search for a virtual override of a method declared on an interface.
                    if (declaringTypeIsClass)
                    {
                        int slot = associateMethodHandle.GetSlot();

                        // Find the override visible from the reflected type
                        associateMethodHandle = reflectedTypeHandle.GetMethodAt(slot);
                    }
                }
            }

            MethodAttributes visibility = methAttr & MethodAttributes.MemberAccessMask;
            bool isPublic = visibility == MethodAttributes.Public;
            bool isNonProtectedInternal = visibility == MethodAttributes.Assembly;
            bool isStatic =(methAttr & MethodAttributes.Static) != 0;

            RuntimeMethodInfo associateMethod = 
                RuntimeType.GetMethodBase(reflectedTypeHandle, associateMethodHandle) as RuntimeMethodInfo;

            // suppose a property was mapped to a method not in the derivation hierarchy of the reflectedTypeHandle
            if (associateMethod == null)
                associateMethod = reflectedTypeHandle.GetRuntimeType().Module.ResolveMethod(tkMethod, null, null) as RuntimeMethodInfo;

            return associateMethod;
        }
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:69,代码来源:xxxinfos.cs


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