30
Is it possible to get a method name from an action? I know I could always pass a string, but I was hoping for something a little more clever.
public bool DeviceCommand(Action apiCall)
{
//It would be nice to log the method name that was passed in
try
{
apiCall();
}
catch (Exception exc)
{
LogException(exc);
return false;
}
return true;
}
Usage looks like this:
void MyMethod()
(
DeviceCommand(() => api.WriteConfig(config));
)