Esempio n. 1
0
        public Condition <T> Compare(string field, EBasicOperator oper)
        {
            Contract.Requires(!String.IsNullOrWhiteSpace(field));
            Contract.Requires(oper != EBasicOperator.None);
            CheckRoot();

            BasicCondition <T> condition = new BasicCondition <T>();

            ClauseVariable var = new ClauseVariable();

            var.Name = field;
            condition.LeftElement = var;

            condition.Operator = oper;

            AddCondition(condition);
            return(condition);
        }
Esempio n. 2
0
        private Condition <T> AddClause(ClauseElement clause)
        {
            Condition <T> parent = stack.Peek();

            if (parent.GetType() == typeof(ListCondition <T>))
            {
                ListCondition <T> list = (ListCondition <T>)parent;
                if (list.IsClosed())
                {
                    throw new QueryException(String.Format("Invalid Stack State: List condition is already closed. [type={0}]", list.GetType().FullName));
                }
                if (clause.GetType() != typeof(ClauseValue))
                {
                    throw new QueryException(String.Format("Invalid Clause: Expected Value clause. [type={0}]", clause.GetType().FullName));
                }
                list.AddValue((ClauseValue)clause);

                return(list);
            }
            else if (parent.GetType() == typeof(BasicCondition <T>))
            {
                BasicCondition <T> condition = (BasicCondition <T>)parent;
                if (condition.IsClosed())
                {
                    throw new QueryException(String.Format("Invalid Stack State: List condition is already closed. [type={0}]", condition.GetType().FullName));
                }
                if (condition.LeftElement == null)
                {
                    condition.LeftElement = clause;
                }
                else
                {
                    condition.RightElement = clause;
                }
                return(condition);
            }
            throw new QueryException(String.Format("Invalid Stack State: Cannot add clause. [type={0}]", parent.GetType().FullName));
        }