public bool Evaluate(Dictionary <string, object> variables) { switch (Operator) { case Operator.LessThan: return(LeftExpr.Evaluate(variables) < RightExpr.Evaluate(variables)); case Operator.LessThanOrEqual: return(LeftExpr.Evaluate(variables) <= RightExpr.Evaluate(variables)); case Operator.Equal: return(Math.Abs(LeftExpr.Evaluate(variables) - RightExpr.Evaluate(variables)) < double.Epsilon); case Operator.NotEqual: return(Math.Abs(LeftExpr.Evaluate(variables) - RightExpr.Evaluate(variables)) > double.Epsilon); case Operator.GreaterThanOrEqual: return(LeftExpr.Evaluate(variables) >= RightExpr.Evaluate(variables)); case Operator.GreaterThan: return(LeftExpr.Evaluate(variables) > RightExpr.Evaluate(variables)); default: throw new NotSupportedException(String.Format("Operator {0} not supported", Operator)); } }
public bool Evaluate(Dictionary <string, object> variables) { switch (Operator) { case Operator.Equal: return(LeftExpr.Evaluate(variables) == RightExpr.Evaluate(variables)); case Operator.NotEqual: return(LeftExpr.Evaluate(variables) != RightExpr.Evaluate(variables)); default: throw new NotSupportedException(string.Format("Operator {0} not supported", Operator)); } }
public double Evaluate(Dictionary <string, object> variables) { switch (Operator) { case Operator.Plus: return(RightExpr == null? LeftExpr.Evaluate(variables) : LeftExpr.Evaluate(variables) + RightExpr.Evaluate(variables)); case Operator.Minus: return(RightExpr == null ? -LeftExpr.Evaluate(variables) : LeftExpr.Evaluate(variables) - RightExpr.Evaluate(variables)); case Operator.Mult: return(LeftExpr.Evaluate(variables) * RightExpr.Evaluate(variables)); case Operator.Div: return(LeftExpr.Evaluate(variables) / RightExpr.Evaluate(variables)); case Operator.Mod: return(LeftExpr.Evaluate(variables) % RightExpr.Evaluate(variables)); case Operator.BitwiseAnd: return((int)LeftExpr.Evaluate(variables) & (int)RightExpr.Evaluate(variables)); case Operator.BitwiseOr: return((int)LeftExpr.Evaluate(variables) | (int)RightExpr.Evaluate(variables)); case Operator.BitwiseXor: return((int)LeftExpr.Evaluate(variables) ^ (int)RightExpr.Evaluate(variables)); case Operator.BitwiseComplement: return(~(int)LeftExpr.Evaluate(variables)); case Operator.LeftShift: return((int)LeftExpr.Evaluate(variables) << (int)RightExpr.Evaluate(variables)); case Operator.RightShift: return((int)LeftExpr.Evaluate(variables) >> (int)RightExpr.Evaluate(variables)); default: throw new NotSupportedException(string.Format("operator {0} not support", Operator)); } }
public double Evaluate(Dictionary <string, object> variables) { return(ConditionExpr.Evaluate(variables) ? LeftExpr.Evaluate(variables) : RightExpr.Evaluate(variables)); }