Example #1
0
 public bool Eval()
 {
     if (Condition(Data))
     {
         return((TrueChild == null) ? true : TrueChild.Eval());
     }
     else
     {
         return((FalseChild == null) ? false : FalseChild.Eval());
     }
 }
Example #2
0
        public decimal Eval(Dictionary <string, object> values)
        {
            Node condition  = (Node)(Condition);
            var  leftValue  = condition.LeftChild.Eval(values);
            var  rightValue = condition.RightChild.Eval(values);

            switch (condition.Value)
            {
            //Equality
            case "=":
                if (leftValue == rightValue)
                {
                    return(TrueChild.Eval(values));
                }
                else
                {
                    return(FalseChild.Eval(values));
                }

            case "!=":
                if (leftValue != rightValue)
                {
                    return(TrueChild.Eval(values));
                }
                else
                {
                    return(FalseChild.Eval(values));
                }

            //Relational
            case ">=":
                if (leftValue >= rightValue)
                {
                    return(TrueChild.Eval(values));
                }
                else
                {
                    return(FalseChild.Eval(values));
                }

            case "<=":
                if (leftValue <= rightValue)
                {
                    return(TrueChild.Eval(values));
                }
                else
                {
                    return(FalseChild.Eval(values));
                }

            case ">":
                if (leftValue > rightValue)
                {
                    return(TrueChild.Eval(values));
                }
                else
                {
                    return(FalseChild.Eval(values));
                }

            case "<":
                if (leftValue < rightValue)
                {
                    return(TrueChild.Eval(values));
                }
                else
                {
                    return(FalseChild.Eval(values));
                }
            }

            return(FalseChild.Eval(values));
        }