本文整理汇总了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();
}
示例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);
}
示例3: IsDefined
internal static bool IsDefined(RuntimeMethodInfo method)
{
return (method.GetMethodImplementationFlags() & MethodImplAttributes.PreserveSig) != 0;
}
示例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);
}