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


C# RuntimeMethodInfo.GetMethodImplementationFlags方法代码示例

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


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

示例1: GetCustomAttribute

 internal static Attribute GetCustomAttribute(RuntimeMethodInfo method)
 {
     if ((method.GetMethodImplementationFlags() & MethodImplAttributes.PreserveSig) == MethodImplAttributes.IL)
     {
         return null;
     }
     return new PreserveSigAttribute();
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:8,代码来源:PreserveSigAttribute.cs

示例2: GetCustomAttribute

        [System.Security.SecurityCritical]  // auto-generated
        internal static Attribute GetCustomAttribute(RuntimeMethodInfo method)
        {
            if ((method.Attributes & MethodAttributes.PinvokeImpl) == 0)
                return null;

#if !MONO
            MetadataImport scope = ModuleHandle.GetMetadataImport(method.Module.ModuleHandle.GetRuntimeModule());
#endif
            string entryPoint, dllName = null;
            int token = method.MetadataToken;
            PInvokeAttributes flags = 0;

#if MONO
            ((MonoMethod)method).GetPInvoke(out flags, out entryPoint, out dllName);
#else
            scope.GetPInvokeMap(token, out flags, out entryPoint, out dllName);
#endif

            CharSet charSet = CharSet.None;

            switch (flags & PInvokeAttributes.CharSetMask)
            {
                case PInvokeAttributes.CharSetNotSpec: charSet = CharSet.None; break;
                case PInvokeAttributes.CharSetAnsi: charSet = CharSet.Ansi; break;
                case PInvokeAttributes.CharSetUnicode: charSet = CharSet.Unicode; break;
                case PInvokeAttributes.CharSetAuto: charSet = CharSet.Auto; break;

                // Invalid: default to CharSet.None
                default: break;
            }

            CallingConvention callingConvention = CallingConvention.Cdecl;

            switch (flags & PInvokeAttributes.CallConvMask)
            {
                case PInvokeAttributes.CallConvWinapi: callingConvention = CallingConvention.Winapi; break;
                case PInvokeAttributes.CallConvCdecl: callingConvention = CallingConvention.Cdecl; break;
                case PInvokeAttributes.CallConvStdcall: callingConvention = CallingConvention.StdCall; break;
                case PInvokeAttributes.CallConvThiscall: callingConvention = CallingConvention.ThisCall; break;
                case PInvokeAttributes.CallConvFastcall: callingConvention = CallingConvention.FastCall; break;

                // Invalid: default to CallingConvention.Cdecl
                default: break;
            }

            bool exactSpelling = (flags & PInvokeAttributes.NoMangle) != 0;
            bool setLastError = (flags & PInvokeAttributes.SupportsLastError) != 0;
            bool bestFitMapping = (flags & PInvokeAttributes.BestFitMask) == PInvokeAttributes.BestFitEnabled;
            bool throwOnUnmappableChar = (flags & PInvokeAttributes.ThrowOnUnmappableCharMask) == PInvokeAttributes.ThrowOnUnmappableCharEnabled;
            bool preserveSig = (method.GetMethodImplementationFlags() & MethodImplAttributes.PreserveSig) != 0;

            return new DllImportAttribute(
                dllName, entryPoint, charSet, exactSpelling, setLastError, preserveSig,
                callingConvention, bestFitMapping, throwOnUnmappableChar);
        }
开发者ID:razzfazz,项目名称:mono,代码行数:56,代码来源:attributes.cs

示例3: IsDefined

 internal static bool IsDefined(RuntimeMethodInfo method)
 {
     return (method.GetMethodImplementationFlags() & MethodImplAttributes.PreserveSig) != 0;
 }
开发者ID:razzfazz,项目名称:mono,代码行数:4,代码来源:attributes.cs

示例4: GetCustomAttribute

        internal static Attribute GetCustomAttribute(RuntimeMethodInfo method)
        {
            string str;
            if ((method.Attributes & MethodAttributes.PinvokeImpl) == MethodAttributes.PrivateScope)
            {
                return null;
            }
            MetadataImport metadataImport = ModuleHandle.GetMetadataImport(method.Module.ModuleHandle.GetRuntimeModule());
            string importDll = null;
            int metadataToken = method.MetadataToken;
            PInvokeAttributes bestFitUseAssem = PInvokeAttributes.BestFitUseAssem;
            metadataImport.GetPInvokeMap(metadataToken, out bestFitUseAssem, out str, out importDll);
            System.Runtime.InteropServices.CharSet none = System.Runtime.InteropServices.CharSet.None;
            switch ((bestFitUseAssem & PInvokeAttributes.CharSetAuto))
            {
                case PInvokeAttributes.BestFitUseAssem:
                    none = System.Runtime.InteropServices.CharSet.None;
                    break;

                case PInvokeAttributes.CharSetAnsi:
                    none = System.Runtime.InteropServices.CharSet.Ansi;
                    break;

                case PInvokeAttributes.CharSetUnicode:
                    none = System.Runtime.InteropServices.CharSet.Unicode;
                    break;

                case PInvokeAttributes.CharSetAuto:
                    none = System.Runtime.InteropServices.CharSet.Auto;
                    break;
            }
            System.Runtime.InteropServices.CallingConvention cdecl = System.Runtime.InteropServices.CallingConvention.Cdecl;
            switch ((bestFitUseAssem & PInvokeAttributes.CallConvMask))
            {
                case PInvokeAttributes.CallConvStdcall:
                    cdecl = System.Runtime.InteropServices.CallingConvention.StdCall;
                    break;

                case PInvokeAttributes.CallConvThiscall:
                    cdecl = System.Runtime.InteropServices.CallingConvention.ThisCall;
                    break;

                case PInvokeAttributes.CallConvFastcall:
                    cdecl = System.Runtime.InteropServices.CallingConvention.FastCall;
                    break;

                case PInvokeAttributes.CallConvWinapi:
                    cdecl = System.Runtime.InteropServices.CallingConvention.Winapi;
                    break;

                case PInvokeAttributes.CallConvCdecl:
                    cdecl = System.Runtime.InteropServices.CallingConvention.Cdecl;
                    break;
            }
            bool exactSpelling = (bestFitUseAssem & PInvokeAttributes.NoMangle) != PInvokeAttributes.BestFitUseAssem;
            bool setLastError = (bestFitUseAssem & PInvokeAttributes.SupportsLastError) != PInvokeAttributes.BestFitUseAssem;
            bool bestFitMapping = (bestFitUseAssem & PInvokeAttributes.BestFitMask) == PInvokeAttributes.BestFitEnabled;
            bool throwOnUnmappableChar = (bestFitUseAssem & PInvokeAttributes.ThrowOnUnmappableCharMask) == PInvokeAttributes.ThrowOnUnmappableCharEnabled;
            return new DllImportAttribute(importDll, str, none, exactSpelling, setLastError, (method.GetMethodImplementationFlags() & MethodImplAttributes.PreserveSig) != MethodImplAttributes.IL, cdecl, bestFitMapping, throwOnUnmappableChar);
        }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:60,代码来源:DllImportAttribute.cs


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