示例#1
0
        public Condition <T> Or()
        {
            CheckRoot();
            OrCondition <T> or = new OrCondition <T>();

            AddCondition(or);
            return(or);
        }
示例#2
0
        private void AddCondition(Condition <T> condition)
        {
            Condition <T> parent = stack.Peek();

            if (parent.GetType() == typeof(ConditionGroup <T>))
            {
                ConditionGroup <T> group = (ConditionGroup <T>)parent;
                if (group.IsClosed())
                {
                    throw new QueryException(String.Format("Invalid Stack State: Group condition is already closed. [type={0}]", group.GetType().FullName));
                }
                group.Add(condition);
            }
            else if (parent.GetType() == typeof(AndCondition <T>))
            {
                AndCondition <T> and = (AndCondition <T>)parent;
                if (and.IsClosed())
                {
                    throw new QueryException(String.Format("Invalid Stack State: And condition is already closed. [type={0}]", and.GetType().FullName));
                }
                and.Add(condition);
            }
            else if (parent.GetType() == typeof(AndCondition <T>))
            {
                AndCondition <T> and = (AndCondition <T>)parent;
                if (and.IsClosed())
                {
                    throw new QueryException(String.Format("Invalid Stack State: And condition is already closed. [type={0}]", and.GetType().FullName));
                }
                and.Add(condition);
            }
            else if (parent.GetType() == typeof(OrCondition <T>))
            {
                OrCondition <T> or = (OrCondition <T>)parent;
                if (or.IsClosed())
                {
                    throw new QueryException(String.Format("Invalid Stack State: Or condition is already closed. [type={0}]", or.GetType().FullName));
                }
                or.Add(condition);
            }
            stack.Push(condition);
        }