private static string ToString(object value) { var sb = new StringBuilder(); EvaluatorEngine.FormatLiteral(value, sb); return(sb.ToString()); }
/// <summary> /// Create an evaluator that always evaluates to the given /// constant <paramref name="value"/>. This is useful to /// substitute default values where no expression is provided. /// </summary> /// <param name="value">The constant value.</param> /// <param name="clause">The value for the evaluator's <see cref="Clause"/> /// property (optional).</param> public static ExpressionEvaluator CreateConstant(object value, string clause = null) { var engine = new EvaluatorEngine(); engine.EmitValue(value); engine.EmitCode(OpCode.End); engine.Commit(); return(new ExpressionEvaluator(engine, clause ?? ToString(value))); }
public ParseState(string text, int index, EvaluatorEngine target, StringComparison comparison) { _text = text ?? string.Empty; Position = _index = index; Token = TokenType.None; Value = null; Target = target ?? new EvaluatorEngine(); Comparison = comparison; _buffer = new StringBuilder(); }
private ExpressionEvaluator(EvaluatorEngine engine, string clause = null) { Clause = clause ?? string.Empty; _engine = engine; }