コード例 #1
0
ファイル: ExpressionBuilder.cs プロジェクト: danfma/db4o-net
 /// <summary>Optimizations: !(Bool)-&gt;(!Bool), !!X-&gt;X, !(X==Bool)-&gt;(X==!Bool)
 ///     </summary>
 public virtual IExpression Not(IExpression expr)
 {
     if (expr.Equals(BoolConstExpression.True))
     {
         return(BoolConstExpression.False);
     }
     if (expr.Equals(BoolConstExpression.False))
     {
         return(BoolConstExpression.True);
     }
     if (expr is NotExpression)
     {
         return(((NotExpression)expr).Expr());
     }
     if (expr is ComparisonExpression)
     {
         ComparisonExpression cmpExpr = (ComparisonExpression)expr;
         if (cmpExpr.Right() is ConstValue)
         {
             ConstValue rightConst = (ConstValue)cmpExpr.Right();
             if (rightConst.Value() is bool)
             {
                 bool boolVal = (bool)rightConst.Value();
                 // new Boolean() instead of Boolean.valueOf() for .NET conversion
                 return(new ComparisonExpression(cmpExpr.Left(), new ConstValue(!boolVal), cmpExpr
                                                 .Op()));
             }
         }
     }
     return(new NotExpression(expr));
 }
コード例 #2
0
ファイル: SODAMethodBuilder.cs プロジェクト: danfma/db4o-net
 public virtual void Visit(ComparisonExpression expression)
 {
     this.LoadQuery();
     this.Descend(this.FieldNames(expression.Left()));
     expression.Right().Accept(this.ComparisonEmitter());
     this.Constrain(expression.Op());
 }
コード例 #3
0
ファイル: SODAQueryBuilder.cs プロジェクト: git-thinh/limada
            public virtual void Visit(ComparisonExpression expression)
            {
                IQuery subQuery = Descend(expression.Left());
                ComparisonQueryGeneratingVisitor visitor = new ComparisonQueryGeneratingVisitor(_predicate
                                                                                                , _classSource, _referenceResolver);

                expression.Right().Accept(visitor);
                _constraint = subQuery.Constrain(visitor.Value());
                ComparisonOperator op = expression.Op();

                if (op.Equals(ComparisonOperator.ValueEquality))
                {
                    return;
                }
                if (op.Equals(ComparisonOperator.ReferenceEquality))
                {
                    _constraint.Identity();
                    return;
                }
                if (op.Equals(ComparisonOperator.Greater))
                {
                    _constraint.Greater();
                    return;
                }
                if (op.Equals(ComparisonOperator.Smaller))
                {
                    _constraint.Smaller();
                    return;
                }
                if (op.Equals(ComparisonOperator.Contains))
                {
                    _constraint.Contains();
                    return;
                }
                if (op.Equals(ComparisonOperator.StartsWith))
                {
                    _constraint.StartsWith(true);
                    return;
                }
                if (op.Equals(ComparisonOperator.EndsWith))
                {
                    _constraint.EndsWith(true);
                    return;
                }
                throw new Exception("Can't handle constraint: " + op);
            }
コード例 #4
0
        override public void Visit(ComparisonExpression expression)
        {
            TypeReference fieldType = GetFieldType(expression.Left());

            if (!fieldType.IsValueType)
            {
                return;
            }

            ConstValue constValue = expression.Right() as ConstValue;

            if (constValue == null)
            {
                return;
            }

            AdjustConstValue(fieldType, constValue);
        }