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));
            }
        }
Beispiel #2
0
 public override void WriteToStream(IndentStream stream)
 {
     LeftExpr.WriteToStream(stream);
     stream.Write(" BETWEEN ");
     StartExpr.WriteToStream(stream);
     stream.Write(" AND ");
     EndExpr.WriteToStream(stream);
 }
Beispiel #3
0
 public override void SaveToXml(XmlElement xml)
 {
     base.SaveToXml(xml);
     if (LeftExpr != null)
     {
         LeftExpr.SaveToXml(xml.AddChild("LeftExpr"));
     }
     if (RightExpr != null)
     {
         RightExpr.SaveToXml(xml.AddChild("RightExpr"));
     }
 }
Beispiel #4
0
 public override void ForEachChild(Action <IDmlfNode> action)
 {
     base.ForEachChild(action);
     if (LeftExpr != null)
     {
         LeftExpr.ForEachChild(action);
     }
     if (RightExpr != null)
     {
         RightExpr.ForEachChild(action);
     }
 }
Beispiel #5
0
 public override void GenSql(ISqlDumper dmp)
 {
     LeftExpr.GenSql(dmp);
     if (CollateSpec != null)
     {
         dmp.Put(" ^collate %s ", CollateSpec);
     }
     dmp.Put(Relation);
     RightExpr.GenSql(dmp);
     if (CollateSpec != null)
     {
         dmp.Put(" ^collate %s ", CollateSpec);
     }
 }
Beispiel #6
0
        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));
            }
        }
Beispiel #8
0
        public override void GenSql(ISqlDumper dmp)
        {
            dmp.Put("(");

            LeftExpr.GenSql(dmp);
            dmp.Put("=");
            RightExpr.GenSql(dmp);

            dmp.Put(" ^or ");
            dmp.Put("(");
            LeftExpr.GenSql(dmp);
            dmp.Put("^is ^null");
            dmp.Put(" ^and ");
            RightExpr.GenSql(dmp);
            dmp.Put(" ^is ^null ");
            dmp.Put(")");

            dmp.Put(")");
        }
Beispiel #9
0
        public override void GenSql(ISqlDumper dmp)
        {
            dmp.Put("(");

            LeftExpr.GenSql(dmp);
            if (CollateSpec != null)
            {
                dmp.Put(" ^collate %s ", CollateSpec);
            }
            dmp.Put("<>");
            RightExpr.GenSql(dmp);
            if (CollateSpec != null)
            {
                dmp.Put(" ^collate %s ", CollateSpec);
            }

            dmp.Put("^or");
            dmp.Put("(");
            LeftExpr.GenSql(dmp);
            dmp.Put("^is ^null");
            dmp.Put(" ^and");
            RightExpr.GenSql(dmp);
            dmp.Put("^is ^not ^null");
            dmp.Put(")");

            dmp.Put("or");
            dmp.Put("(");
            LeftExpr.GenSql(dmp);
            dmp.Put("^is ^not ^null");
            dmp.Put(" ^and");
            RightExpr.GenSql(dmp);
            dmp.Put("^is ^null");
            dmp.Put(")");

            dmp.Put(")");
        }
Beispiel #10
0
 public override void GenSql(ISqlDumper dmp, IDmlfHandler handler)
 {
     LeftExpr.GenSql(dmp, handler);
     dmp.Put(" ^like ");
     RightExpr.GenSql(dmp, handler);
 }
 public double Evaluate(Dictionary <string, object> variables)
 {
     return(ConditionExpr.Evaluate(variables) ? LeftExpr.Evaluate(variables) : RightExpr.Evaluate(variables));
 }
Beispiel #12
0
 public override void GenSql(ISqlDumper dmp)
 {
     LeftExpr.GenSql(dmp);
     dmp.Put(" ^not ^in ");
     RightExpr.GenSql(dmp);
 }