If I have a method that is building code using Expression
trees, to handle runtime types, how can I make an Expression
that references a parameter to the method?
E.g. in the below code, how do I build Expression
s to pass in that reference the method parameters?
public static bool ExpressionContains(string s, string sub) {
var cmi = typeof(String).GetMethod("Contains", new[] { typeof(string) });
var body = Expression.Call(cmi, s ???, sub ???);
return Expression.Lambda<Func<bool>>(body).Compile().Invoke();
}
Aucun commentaire:
Enregistrer un commentaire