2009-11-25 78 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

相關問題