internal object Evaluate(GetVariableDelegate varDelegate) { switch (this.Type) { case NodeType.Literal: return(this.Value); case NodeType.Operator: object left = null; if (this.Left != null) { left = this.Left.Evaluate(varDelegate); } object right = this.Right.Evaluate(varDelegate); return(this.Operator.ApplyOperator(left, right)); case NodeType.Symbol: string key = this.Value.ToString().ToLower(); object value = varDelegate(key); if (value != (object)key) { return(value); } throw new Exception("Symbol Undefined: \"" + this.Value + "\""); } throw new Exception("Invalid Node Type"); }
public object Evaluate(GetVariableDelegate varDelegate) { if (varDelegate == null) { throw new ArgumentNullException("varDelegate"); } return(rootNode.Evaluate(varDelegate)); }