Example #1
0
        public void AddClause(string text, ChainOperator chainOp)
        {
            if (text == null)
            {
                throw new ArgumentNullException("text");
            }
            if (text.Length == 0)
            {
                throw new ArgumentException("Clause cannot be empty", "text");
            }

            if (string.IsNullOrEmpty(this.Text))
            {
                this.Text = text;
            }
            else
            {
                switch (chainOp)
                {
                case ChainOperator.And:
                    this.Text = MoveSettingsToTheEnd(string.Format("+({0}) +({1})", Text, text)).Trim();
                    break;

                case ChainOperator.Or:
                    this.Text = MoveSettingsToTheEnd(string.Format("({0}) {1}", Text, text));
                    break;
                }
            }
        }
Example #2
0
        public static string AddClause(string originalText, string addition, ChainOperator chainOp)
        {
            if (addition == null)
            {
                throw new ArgumentNullException("addition");
            }
            if (addition.Length == 0)
            {
                throw new ArgumentException("Clause cannot be empty", "addition");
            }

            if (string.IsNullOrEmpty(originalText))
            {
                return(addition);
            }

            var queryText = string.Empty;

            switch (chainOp)
            {
            case ChainOperator.And:
                queryText = MoveSettingsToTheEnd(string.Format("+({0}) +({1})", originalText, addition)).Trim();
                break;

            case ChainOperator.Or:
                queryText = MoveSettingsToTheEnd(string.Format("({0}) {1}", originalText, addition));
                break;
            }

            return(queryText);
        }
Example #3
0
        private void AddClausePrivate(string text, ChainOperator chainOp)
        {
            if (text == null)
            {
                throw new ArgumentNullException("text");
            }
            if (text.Length == 0)
            {
                throw new ArgumentException("Clause cannot be empty", "text");
            }

            if (string.IsNullOrEmpty(this.Text))
            {
                this.Text = text;
            }
            else
            {
                // we can modify the _text variable here directly because it was already fixed at init time
                switch (chainOp)
                {
                case ChainOperator.And:
                    this._text = MoveSettingsToTheEnd(string.Format("+({0}) +({1})", Text, text)).Trim();
                    break;

                case ChainOperator.Or:
                    this._text = MoveSettingsToTheEnd(string.Format("({0}) {1}", Text, text));
                    break;
                }
            }
        }
Example #4
0
		public ExpressionList(ChainOperator operatorType, params Expression[] expressions) : this(operatorType)
		{
			foreach (Expression exp in expressions)
				if (exp == null)
					throw new ArgumentOutOfRangeException("expressions", "Expression parameter cannot be null");
            foreach (var expression in expressions)
                Add(expression);
		}
Example #5
0
 public ExpressionList(ChainOperator operatorType, Expression expression) : this(operatorType)
 {
     if (expression == null)
     {
         throw new ArgumentNullException("expression");
     }
     Add(expression);
 }
Example #6
0
		public ExpressionList(ChainOperator operatorType, Expression exp0, Expression exp1) : this(operatorType)
		{
			if (exp0 == null)
				throw new ArgumentNullException("exp0");
			if (exp1 == null)
				throw new ArgumentNullException("exp1");
			Add(exp0);
			Add(exp1);
		}
Example #7
0
        private static Expression ParseExpressionList(XmlNode node, XmlNamespaceManager nsmgr, SchemaRoot schema)
        {
            ChainOperator  op       = (ChainOperator)Enum.Parse(typeof(ChainOperator), node.LocalName);
            ExpressionList exprList = new ExpressionList(op);

            foreach (XmlNode subNode in node.SelectNodes("x:*", nsmgr))
            {
                exprList.Add(ParseExpression(subNode, nsmgr, schema));
            }
            return(exprList);
        }
Example #8
0
        public void AddClause(string text, ChainOperator chainOp, params object[] parameters)
        {
            var isSafe = this.IsSafe && IsSafeQuery(text);

            if (parameters != null && parameters.Length > 0)
            {
                text = SubstituteParameters(text, parameters);
            }
            this.IsSafe = isSafe;
            AddClausePrivate(text, chainOp);
        }
Example #9
0
 public ExpressionList(ChainOperator operatorType, Expression exp0, Expression exp1) : this(operatorType)
 {
     if (exp0 == null)
     {
         throw new ArgumentNullException("exp0");
     }
     if (exp1 == null)
     {
         throw new ArgumentNullException("exp1");
     }
     Add(exp0);
     Add(exp1);
 }
Example #10
0
 public ExpressionList(ChainOperator operatorType, params Expression[] expressions) : this(operatorType)
 {
     foreach (Expression exp in expressions)
     {
         if (exp == null)
         {
             throw new ArgumentOutOfRangeException("expressions", "Expression parameter cannot be null");
         }
     }
     foreach (var expression in expressions)
     {
         Add(expression);
     }
 }
Example #11
0
        public ChainSelector(Selector prevSelector, Selector nextSelector, ChainOperator chainOperator)
        {
            if (prevSelector == null)
            {
                throw new ArgumentNullException(nameof(prevSelector));
            }
            if (nextSelector == null)
            {
                throw new ArgumentNullException(nameof(nextSelector));
            }

            Priority       = Math.Max(prevSelector.Priority, nextSelector.Priority);
            _prevSelector  = prevSelector;
            _nextSelector  = nextSelector;
            _chainOperator = chainOperator;
        }
Example #12
0
        public void AddClause(Expression expression, ChainOperator chainOp)
        {
            if (expression == null)
            {
                throw new ArgumentNullException("expression");
            }

            ExpressionList finalExpList;
            var            origExpList = expression as ExpressionList;

            if (origExpList != null)
            {
                finalExpList = origExpList;
            }
            else
            {
                finalExpList = new ExpressionList(chainOp);
                finalExpList.Add(expression);
            }

            this.Text = AddFilterToNodeQuery(Text, finalExpList.ToXml());
        }
Example #13
0
        public void AddClause(string text, ChainOperator chainOp)
        {
            if (text == null)
                throw new ArgumentNullException("text");
            if (text.Length == 0)
                throw new ArgumentException("Clause cannot be empty", "text");

            if (string.IsNullOrEmpty(this.Text))
                this.Text = text;
            else
            {
                switch (chainOp)
                {
                    case ChainOperator.And:
                        this.Text = MoveSettingsToTheEnd(string.Format("+({0}) +({1})", Text, text)).Trim();
                        break;
                    case ChainOperator.Or:
                        this.Text = MoveSettingsToTheEnd(string.Format("({0}) {1}", Text, text));
                        break;
                }
            }
        }
Example #14
0
        public static string AddClause(string originalText, string addition, ChainOperator chainOp)
        {
            if (addition == null)
                throw new ArgumentNullException("addition");
            if (addition.Length == 0)
                throw new ArgumentException("Clause cannot be empty", "addition");

            if (string.IsNullOrEmpty(originalText))
                return addition;

            var queryText = string.Empty;

            switch (chainOp)
            {
                case ChainOperator.And:
                    queryText = MoveSettingsToTheEnd(string.Format("+({0}) +({1})", originalText, addition)).Trim();
                    break;
                case ChainOperator.Or:
                    queryText = MoveSettingsToTheEnd(string.Format("({0}) {1}", originalText, addition));
                    break;
            }

            return queryText;
        }
Example #15
0
        public void AddClause(Expression expression, ChainOperator chainOp)
        {
            if (expression == null)
                throw new ArgumentNullException("expression");

            ExpressionList finalExpList;
            var origExpList = expression as ExpressionList;
            
            if (origExpList != null)
            {
                finalExpList = origExpList;
            }
            else
            {
                finalExpList = new ExpressionList(chainOp);
                finalExpList.Add(expression);
            }

            this.Text = AddFilterToNodeQuery(Text, finalExpList.ToXml());
        }
Example #16
0
 public ExpressionList(ChainOperator operatorType)
 {
     _operatorType = operatorType;
     _expressions  = new List <Expression>();
 }
Example #17
0
		public ExpressionList(ChainOperator operatorType)
		{
			_operatorType = operatorType;
			_expressions = new List<Expression>();
		}
Example #18
0
 public NodeQuery(ChainOperator operatorType, params Expression[] expressions) : base(operatorType, expressions)
 {
     Initialize();
 }
Example #19
0
		public ExpressionList(ChainOperator operatorType, Expression expression) : this(operatorType)
		{
			if (expression == null)
				throw new ArgumentNullException("expression");
			Add(expression);
		}
Example #20
0
 public void AddClause(string text, ChainOperator chainOp)
 {
     AddClause(text, chainOp, null);
 }