How should I construct Expression tree for string.IndexOf("substring", StringComparison.OrdinalIgnoreCase)
?
I can get it working without the second argument: StringComparison.OrdinalIgnoreCase
. These are my attempts so far:
var methodCall = typeof (string).GetMethod("IndexOf", new[] {typeof (string)});
Expression[] parms = new Expression[]{right, Expression.Constant("StringComparison.OrdinalIgnoreCase", typeof (Enum))};
var exp = Expression.Call(left, methodCall, parms);
return exp;
Also tried this:
var methodCall = typeof (string).GetMethod(method, new[] {typeof (string)});
Expression[] parms = new Expression[]{right, Expression.Parameter(typeof(Enum) , "StringComparison.OrdinalIgnoreCase")};
var exp = Expression.Call(left, methodCall, parms);
return exp;
Please remember that I can get it working if I ignore the OrdinalIgnoreCase
parameter.
Thanks