public void TestExpression() { var expr = "(Age != null) && (Id > 0)"; var context = new ExpressionContext(); var result = context.Create <P>(expr); var flag1 = result.Func(new P { Id = 2, Age = null }); var flag2 = result.Func(new P { Id = 2, Age = 2 }); }
private string ResolveIfNode <T>(IfNode node, T parameter) { if (node.Delegate == null) { lock (this) { var context = new ExpressionContext(); var result = context.Create <T>(node.Test); node.Delegate = result.Func; } } var func = node.Delegate as Func <T, bool>; if (func(parameter)) { return(ResolveTextNode(new TextNode { Value = node.Value })); } return(string.Empty); }