本文整理汇总了C#中System.Reflection.MethodInfo.GetMethodImplementationFlags方法的典型用法代码示例。如果您正苦于以下问题:C# MethodInfo.GetMethodImplementationFlags方法的具体用法?C# MethodInfo.GetMethodImplementationFlags怎么用?C# MethodInfo.GetMethodImplementationFlags使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Reflection.MethodInfo
的用法示例。
在下文中一共展示了MethodInfo.GetMethodImplementationFlags方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PrintMethod
private static void PrintMethod(MethodInfo method)
{
Console.Write("{0} {1}(", method.ReturnType.FullName, method.Name);
foreach (ParameterInfo p in method.GetParameters())
Console.Write("{0}, ", p.ParameterType.FullName);
Console.WriteLine(")");
Console.WriteLine("Attribs: {0}", method.Attributes);
Console.WriteLine("Calling: {0}", method.CallingConvention);
Console.WriteLine("Impl: {0}", method.GetMethodImplementationFlags());
}
示例2: GrabPInvokeImpl
protected MethodInfo GrabPInvokeImpl(MethodInfo Original, TypeBuilder On)
{
if (On == null)
On = GrabType(Original.DeclaringType) as TypeBuilder;
DllImportAttribute Attr = FindCustomAttribute<DllImportAttribute>(Original);
if (Attr == null)
throw new InvalidOperationException("P/Invoke method without a DllImportAttribute");
Type ReturnType = GrabType(Original.ReturnType);
Type[] Parameters = ParameterTypes(Original);
if (MethodsDone.ContainsKey(Original))
return MethodsDone[Original];
MethodBuilder PInvoke = On.DefinePInvokeMethod(Original.Name, Attr.Value, Original.Attributes, Original.CallingConvention,
ReturnType, Parameters, Attr.CallingConvention, Attr.CharSet);
PInvoke.SetImplementationFlags(Original.GetMethodImplementationFlags());
MethodsDone.Add(Original, PInvoke);
return PInvoke;
}
示例3: AppendMethodInfo
static private void AppendMethodInfo(MethodInfo method, StringBuilder sb)
{
sb.Append(".method");
foreach (var attribute in method.GetCustomAttributesData())
{
sb.Append(" ");
AppendCustomAttributeData(attribute, sb);
}
sb.Append(" ");
AppendMethodAttributes(sb, method.Attributes);
sb.Append(" ");
AppendParameterInfo(method.ReturnParameter, sb);
sb.Append(" ");
sb.Append(method.Name);
if (method.IsGenericMethod)
{
sb.Append("<");
foreach (var typeParameter in method.GetGenericArguments())
{
AppendType(typeParameter, sb, true);
AppendComma(sb);
}
RemoveTrailingComma(sb);
sb.Append(">");
}
sb.Append("(");
foreach (var parameter in method.GetParameters())
{
AppendParameterInfo(parameter, sb);
AppendComma(sb);
}
RemoveTrailingComma(sb);
sb.Append(") ");
AppendMethodImplAttributes(sb, method.GetMethodImplementationFlags());
}
示例4: GrabMethod
protected MethodInfo GrabMethod(MethodInfo Original, TypeBuilder On)
{
if (Original == null) return null;
if (MethodsDone.ContainsKey(Original))
return MethodsDone[Original];
if (!Sources.Contains(Original.Module))
return MethodReplaceGenerics(Original);
if (On == null)
On = GrabType(Original.DeclaringType) as TypeBuilder;
if ((Original.Attributes & MethodAttributes.PinvokeImpl) == MethodAttributes.PinvokeImpl)
return GrabPInvokeImpl(Original, On);
Type ReturnType = GrabType(Original.ReturnType);
Type[] Parameters = ParameterTypes(Original);
if (MethodsDone.ContainsKey(Original))
return MethodsDone[Original];
MethodBuilder Builder = On.DefineMethod(Original.Name, Original.Attributes, ReturnType, Parameters);
MethodsDone.Add(Original, Builder);
// Explicit interface implementations require specifying which method is being overridden.
if (Original.IsFinal)
{
if (Original.Name.Contains("."))
{
MethodInfo Overriding = FindBaseMethod(Original, Original.DeclaringType);
if (Overriding != null)
On.DefineMethodOverride(Builder, Overriding);
}
else
{
// Crawl among the interfaces attempting to guess the method that is being overridden.
foreach (Type T in Original.DeclaringType.GetInterfaces())
{
foreach (MethodInfo M in T.GetMethods())
{
if (M.IsAbstract && M.Name == Original.Name)
{
On.DefineMethodOverride(Builder, M);
goto foundoverride; // For lack of "break 2" statement.
}
}
}
}
}
foundoverride:
Builder.SetImplementationFlags(Original.GetMethodImplementationFlags());
CopyMethodBody(Original, Builder);
return Builder;
}