在我的应用程序中,我有一个小动作日志。在那里,我将某些方法的最后几次调用保存在我的应用程序中,如下所示:
saveLastAction(MethodBase.GetCurrentMethod(), getCurrentStatus(), item, /*loadFresh*/ false);
它允许我浏览和刷新我的最后一个动作
public void Refresh(bool loadFresh = true)
{
if (!isInitialized) return;
try
{
lastStatus = getCurrentStatus();
var parameters = lastActionsParameters.Pop();
var method = lastActions.Pop();
//Set the load Fresh parameter to True
parameters[method.GetParameters().First(pi => pi.Name == "loadFresh").Position] = loadFresh;
//Invoke the Method again with the adopted parameters
method.Invoke(this, parameters);
}
catch
{
}
}
在我将调用 saveLastAction 的方法之一更改为异步之前,我工作得很好。从那时起MethodBase.GetCurrentMethod()
只返回 MoveNext 函数,而不是我调用的实际函数。
有没有办法获得被调用函数的实际 MethodBase 对象,无论是在保存还是调用时都没有关系。
最好的问候 lolsharp