You will have to traverse Expression trees
. Here is some sample code:
internal static class myExpressionService
{
public static string Get(Expression<Action> expression)
{
MethodCallExpression methodCallExpression = (MethodCallExpression)expression.Body;
var method = methodCallExpression.Method;
var argument = (ConstantExpression) methodCallExpression.Arguments.First();
return string.Format("{0}.{1}({2})", method.DeclaringType.FullName, method.Name, argument.Value);
}
}
It works if called in this way: string result = myExpressionService.Get(() => myService.Do(1));
The output is: Namespace.IMyService.Do(1)
You can extend/update it to handle your scenario.