如何根据以下签名获取我正在执行的方法的名称:
MyMethodAsync( ()=> myservice.GetCustomer)
public async Task MyMethodAsync(Func<Task> taskToExecute)
{
//Get the name of the task that is executing
// eg "myservice.GetCustomer
taskToExecute.??
}
public async Task MyMethodAsync<T>(Func<Task<T>> taskToExecute)
{
//Get the name of the task that is executing eg
// "myservice.GetCustomer
}
期望的结果:myservice.GetCustomer
我尝试过如下,但它不起作用。理想情况下,我想在没有反思的情况下这样做
string methodName = taskToExecute.GetMethodInfo().Name;