Example #1
0
        /// <summary>
        ///     Applies the required string property condition in the condition part of the query.
        /// </summary>
        /// <param name="value">The expected value for the condition.</param>
        /// <param name="matcher">The matcher to use to check the condition.</param>
        /// <returns>THe operator part of the query.</returns>
        private QueryOperatorPart ApplyMatcher(string value, Matcher <string> matcher)
        {
            if (!(Query.Engine is TreeWalkerSearchEngine))
            {
                throw new QueryConstructionException("Cannot apply matcher - Search engine is not a TreeWalker");
            }

            ConditionPart.ApplyCondition(new StringPropertyCondition(Property, value, matcher));
            return(new QueryOperatorPart(ConditionPart));
        }
Example #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="Instance"></param>
        /// <param name="Condition"></param>
        /// <returns></returns>
        private bool CheckSingleCondition(object Instance, string Condition)
        {
            bool Result = true;

            string[] ConditionParts = Condition.Split("&".ToCharArray());

            foreach (string ConditionPart in ConditionParts)
            {
                string[] ConditionElements = ConditionPart.Split("=".ToCharArray());

                if (ConditionElements.Length == 2)
                {
                    object _value = GetValue(Instance, ConditionElements[0]);
                    String Value  = _value.ToString();

                    if (ConditionElements[1].StartsWith("!"))
                    {
                        String ConditionElement = ConditionElements[1].Substring(1);

                        if (Value == ConditionElement)
                        {
                            Result = false;
                            break;
                        }
                    }
                    else
                    {
                        if (Value != ConditionElements[1])
                        {
                            Result = false;
                            break;
                        }
                    }
                }
            }

            return(Result);
        }
Example #3
0
        /// <summary>
        ///     Sets the active binary operator to a logical "or".
        /// </summary>
        /// <returns>This condition part.</returns>
        public QueryConditionPart Or()
        {
            ConditionPart.SetBinaryOperator(Util.Operators.Or);

            return(ConditionPart);
        }
Example #4
0
        /// <summary>
        ///     Sets the active binary operator to a logical "and".
        /// </summary>
        /// <returns>This condition part.</returns>
        public QueryConditionPart And()
        {
            ConditionPart.SetBinaryOperator(Util.Operators.And);

            return(ConditionPart);
        }
Example #5
0
 /// <summary>
 ///     Applies the required property condition in the condition part of the query.
 /// </summary>
 /// <param name="value">The expected value for the condition.</param>
 /// <returns>THe operator part of the query.</returns>
 private QueryOperatorPart ApplyMatcher(object value)
 {
     ConditionPart.ApplyCondition(new PropertyCondition(Property, value));
     return(new QueryOperatorPart(ConditionPart));
 }