How can I get the arguments values of a MethodCallExpression?
Today I do this way, but isn“t fast enough:
private static object GetArgumentValue(Expression element)
{
LambdaExpression l = Expression.Lambda(Expression.Convert(element, element.Type));
return l.Compile().DynamicInvoke();
}
This method get values from a Expression, but if I know that Expression always come from a MethodCallExpression.Arguments I can optimize it?
I think I can change first line to this, but I don't know if it works for all situations:
LambdaExpression l = Expression.Lambda(element);