public static string GetExpressionString(Expression node) { var exprMachine = new ExpressionMachine(); exprMachine.Visit(node); return(exprMachine.s); }
protected override Expression VisitMethodCall(MethodCallExpression node) { var functionName = node.Method.Name; var machine = new ExpressionMachine(); machine.Visit(node.Arguments[0]); var argString = machine.s; s += Indent() + functionName + " " + argString + ";\n"; return(base.VisitMethodCall(node)); }
string OutputRule(Rule rule) { var s = rule.type.ToString() + " " + rule.applyingTo.name; if (rule.condition != null) { s += " when "; var expr = rule.condition; if (expr is Expression <Predicate <Thing> > thingExpr) { var visitor = new ExpressionMachine(); visitor.Visit(expr); s += visitor.s + ":\n"; } } s += OutputRuleBody(rule); return(s); }