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


C# RuntimeMethodHandle.IsVisibleFromType方法代码示例

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


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

示例1: FilterCustomAttributeRecord

 internal static unsafe bool FilterCustomAttributeRecord(CustomAttributeRecord caRecord, MetadataImport scope, ref Assembly lastAptcaOkAssembly, Module decoratedModule, MetadataToken decoratedToken, RuntimeType attributeFilterType, bool mustBeInheritable, object[] attributes, IList derivedAttributes, out RuntimeType attributeType, out RuntimeMethodHandle ctor, out bool ctorHasParameters, out bool isVarArg)
 {
     ctor = new RuntimeMethodHandle();
     attributeType = null;
     ctorHasParameters = false;
     isVarArg = false;
     IntPtr ptr1 = (IntPtr) (((void*) caRecord.blob.Signature) + caRecord.blob.Length);
     attributeType = decoratedModule.ResolveType(scope.GetParentToken((int) caRecord.tkCtor), null, null) as RuntimeType;
     if (!attributeFilterType.IsAssignableFrom(attributeType))
     {
         return false;
     }
     if (!AttributeUsageCheck(attributeType, mustBeInheritable, attributes, derivedAttributes))
     {
         return false;
     }
     if ((attributeType.Assembly != lastAptcaOkAssembly) && !attributeType.Assembly.AptcaCheck(decoratedModule.Assembly))
     {
         return false;
     }
     lastAptcaOkAssembly = decoratedModule.Assembly;
     ConstArray methodSignature = scope.GetMethodSignature(caRecord.tkCtor);
     isVarArg = (methodSignature[0] & 5) != 0;
     ctorHasParameters = methodSignature[1] != 0;
     if (ctorHasParameters)
     {
         ctor = decoratedModule.ModuleHandle.ResolveMethodHandle((int) caRecord.tkCtor);
     }
     else
     {
         ctor = attributeType.GetTypeHandleInternal().GetDefaultConstructor();
         if (ctor.IsNullHandle() && !attributeType.IsValueType)
         {
             throw new MissingMethodException(".ctor");
         }
     }
     if (ctor.IsNullHandle())
     {
         if (!attributeType.IsVisible && !attributeType.TypeHandle.IsVisibleFromModule(decoratedModule.ModuleHandle))
         {
             return false;
         }
         return true;
     }
     if (ctor.IsVisibleFromModule(decoratedModule))
     {
         return true;
     }
     MetadataToken token = new MetadataToken();
     if (decoratedToken.IsParamDef)
     {
         token = new MetadataToken(scope.GetParentToken((int) decoratedToken));
         token = new MetadataToken(scope.GetParentToken((int) token));
     }
     else if ((decoratedToken.IsMethodDef || decoratedToken.IsProperty) || (decoratedToken.IsEvent || decoratedToken.IsFieldDef))
     {
         token = new MetadataToken(scope.GetParentToken((int) decoratedToken));
     }
     else if (decoratedToken.IsTypeDef)
     {
         token = decoratedToken;
     }
     return (token.IsTypeDef && ctor.IsVisibleFromType(decoratedModule.ModuleHandle.ResolveTypeHandle((int) token)));
 }
开发者ID:randomize,项目名称:VimConfig,代码行数:64,代码来源:CustomAttribute.cs

示例2: FilterCustomAttributeRecord

        internal unsafe static bool FilterCustomAttributeRecord(
            CustomAttributeRecord caRecord, MetadataImport scope, ref Assembly lastAptcaOkAssembly, 
            Module decoratedModule, MetadataToken decoratedToken, RuntimeType attributeFilterType, bool mustBeInheritable,
            object[] attributes, IList derivedAttributes,
            out RuntimeType attributeType, out RuntimeMethodHandle ctor, out bool ctorHasParameters, out bool isVarArg)
        {
            ctor = new RuntimeMethodHandle();
            attributeType = null;
            ctorHasParameters = false;
            isVarArg = false;
            
            IntPtr blobStart = caRecord.blob.Signature;
            IntPtr blobEnd = (IntPtr)((byte*)blobStart + caRecord.blob.Length);

            // Resolve attribute type from ctor parent token found in decorated decoratedModule scope
            attributeType = decoratedModule.ResolveType(scope.GetParentToken(caRecord.tkCtor), null, null) as RuntimeType;

            // Test attribute type against user provided attribute type filter
            if (!(attributeFilterType.IsAssignableFrom(attributeType)))
                return false;

            if (!AttributeUsageCheck(attributeType, mustBeInheritable, attributes, derivedAttributes))
                return false;

            // APTCA checks
            if (attributeType.Assembly != lastAptcaOkAssembly && 
                !attributeType.Assembly.AptcaCheck(decoratedModule.Assembly))
                return false;

            // Cache last successful APTCA check (optimization)
            lastAptcaOkAssembly = decoratedModule.Assembly;

            // Resolve the attribute ctor
            ConstArray ctorSig = scope.GetMethodSignature(caRecord.tkCtor);
            isVarArg = (ctorSig[0] & 0x05) != 0;
            ctorHasParameters = ctorSig[1] != 0;

            if (ctorHasParameters)
            {
                // Resolve method ctor token found in decorated decoratedModule scope
                ctor = decoratedModule.ModuleHandle.ResolveMethodHandle(caRecord.tkCtor);
            }
            else
            {
                // Resolve method ctor token from decorated decoratedModule scope
                ctor = attributeType.GetTypeHandleInternal().GetDefaultConstructor();

                if (ctor.IsNullHandle() && !attributeType.IsValueType)
                    throw new MissingMethodException(".ctor");
            }

            // Visibility checks
            if (ctor.IsNullHandle())
            {
                if (!attributeType.IsVisible && !attributeType.TypeHandle.IsVisibleFromModule(decoratedModule.ModuleHandle))
                    return false;            
                
                return true;
            }
            
            if (ctor.IsVisibleFromModule(decoratedModule))
                return true;
            
            MetadataToken tkParent = new MetadataToken();
                
            if (decoratedToken.IsParamDef)
            {
                tkParent = new MetadataToken(scope.GetParentToken(decoratedToken));
                tkParent = new MetadataToken(scope.GetParentToken(tkParent));
            }               
            else if (decoratedToken.IsMethodDef || decoratedToken.IsProperty || decoratedToken.IsEvent || decoratedToken.IsFieldDef) 
            {
                tkParent = new MetadataToken(scope.GetParentToken(decoratedToken));
            }
            else if (decoratedToken.IsTypeDef)
            {
                tkParent = decoratedToken;
            }
            
            if (tkParent.IsTypeDef)
                return ctor.IsVisibleFromType(decoratedModule.ModuleHandle.ResolveTypeHandle(tkParent));
            
            return false;
        }
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:84,代码来源:customattribute.cs


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