2009-11-25 82 views

回答

2

看,它看起来像它可以:

[MethodImpl(MethodImplOptions.NoInlining)] 
public static MethodBase GetCurrentMethod() 
{ 
    StackCrawlMark lookForMyCaller = StackCrawlMark.LookForMyCaller; 
    return RuntimeMethodInfo.InternalGetCurrentMethod(ref lookForMyCaller); 
} 

InternalGetCurrentMethod样子:

internal static MethodBase InternalGetCurrentMethod(ref StackCrawlMark stackMark) 
{ 
    RuntimeMethodHandle currentMethod = RuntimeMethodHandle.GetCurrentMethod(ref stackMark); 
    if (currentMethod.IsNullHandle()) 
    { 
     return null; 
    } 
    return RuntimeType.GetMethodBase(currentMethod.GetTypicalMethodDefinition()); 
} 
+0

谢谢!我可能会考虑安装反射器。 – emptyset 2009-11-25 19:22:50

相关问题