public void NotWord()
        {
            var context = new ConditionContext("!");

            ConditionParser.Tokenise(context);
            Assert.IsType <Not>(context.Values.First());
        }
 private Expression HandleContains(StringOperatorCondition <T> p_Condition, ConditionContext p_Context)
 {
     return((Expression)Expression.Call(this.GetFieldExpression(p_Context.ParameterExpression, this.m_Condition), "Contains", (Type[])null, new Expression[1]
     {
         this.GetConstantExpression(p_Context.ParameterExpression, this.m_Condition)
     }));
 }
        public void Groups()
        {
            var context = new ConditionContext("()");

            ConditionParser.Tokenise(context);
            Assert.Equal(2, context.Values.Count);
        }
Beispiel #4
0
        public Expression <Func <T, bool> > GetFilterExpression <T>(IEnumerable <string> values) where T : SearchResultItem
        {
            int year = ValidateInput(values.FirstOrDefault());

            // abort if input is no good
            if (year == 0)
            {
                return(null);
            }

            DateTime startTime = new DateTime(year, 1, 1);
            DateTime endTime   = new DateTime(year, 12, 31);

            ParameterExpression expression = Expression.Parameter(typeof(T), "item");
            ConditionContext    context    = new ConditionContext(expression);

            var greaterThan = new Func <Expression, Expression, Expression>(Expression.GreaterThanOrEqual);
            var lessThan    = new Func <Expression, Expression, Expression>(Expression.LessThanOrEqual);

            var dateRangeExpression = Expression.Lambda <Func <T, bool> >(greaterThan(Expression.Property(context.ParameterExpression, typeof(T), SearchResultItemUtil.GetPropertyName <T>(InnerItem.Field_Name)), Expression.Constant(startTime)), new[] { expression });

            dateRangeExpression = Expression.Lambda <Func <T, bool> >(lessThan(Expression.Property(context.ParameterExpression, typeof(T), SearchResultItemUtil.GetPropertyName <T>(InnerItem.Field_Name)), Expression.Constant(endTime)), new[] { expression });

            return(dateRangeExpression);
        }
Beispiel #5
0
        public Expression <Func <T, bool> > GetFilterExpression <T>(IEnumerable <string> values) where T : SearchResultItem
        {
            DateTime startDate = DateTime.MinValue;
            DateTime endDate   = DateTime.MinValue;

            DateTime.TryParse(values.First(), out startDate);
            DateTime.TryParse(values.Last(), out endDate);

            // lets make sure items are within the day.
            if (endDate > DateTime.MinValue)
            {
                endDate = endDate.AddHours(23);
                endDate = endDate.AddMinutes(59);
                endDate = endDate.AddSeconds(59);
            }

            ParameterExpression expression = Expression.Parameter(typeof(T), "item");
            ConditionContext    context    = new ConditionContext(expression);

            var greaterThan = new Func <Expression, Expression, Expression>(Expression.GreaterThanOrEqual);
            var lessThan    = new Func <Expression, Expression, Expression>(Expression.LessThanOrEqual);

            var dateRangeExpression = Expression.Lambda <Func <T, bool> >(greaterThan(Expression.Property(context.ParameterExpression, typeof(T), SearchResultItemUtil.GetPropertyName <T>(InnerItem.Field_Name)), Expression.Constant(startDate)), new[] { expression });

            if (endDate > DateTime.MinValue)
            {
                dateRangeExpression = dateRangeExpression.And(Expression.Lambda <Func <T, bool> >(lessThan(Expression.Property(context.ParameterExpression, typeof(T), SearchResultItemUtil.GetPropertyName <T>(InnerItem.Field_Name)), Expression.Constant(endDate)), new[] { expression }));
            }

            return(dateRangeExpression);
        }
 public override Expression GetQueryExpression(ConditionContext p_Context)
 {
     return(Expression.Call(this.GetTypedFieldValueExpression(p_Context), "Contains", (Type[])null, new Expression[1]
     {
         this.GetTypedValueExpression(p_Context)
     }));
 }
        /// <summary>
        /// Determines whether or not a rule should execute.
        /// </summary>
        /// <param name="rule">The rule</param>
        /// <param name="propertyPath">Property path (eg Customer.Address.Line1)</param>
        /// <param name="context">Contextual information</param>
        /// <returns>Whether or not the validator can execute.</returns>
        public bool CanExecute(IPropertyRule rule, string propertyPath, ConditionContext context)
        {
            // By default we ignore any rules part of a RuleSet.
            // TODO
            //if (!string.IsNullOrEmpty(rule.RuleSet)) return false;

            return true;
        }
 private Expression HandleMatchRegex(StringOperatorCondition <T> p_Condition, ConditionContext p_Context)
 {
     return((Expression)Expression.Call((Expression)null, typeof(MethodExtensions).GetMethod("Matches", new Type[2]
     {
         typeof(string),
         typeof(string)
     }), this.GetFieldExpression(p_Context.ParameterExpression, this.m_Condition), this.GetConstantExpression(p_Context.ParameterExpression, this.m_Condition)));
 }
Beispiel #9
0
 /*********
 ** Public methods
 *********/
 /// <summary>Construct an instance.</summary>
 /// <param name="monitor">Encapsulates monitoring and logging.</param>
 /// <param name="conditionFactory">Handles constructing, permuting, and updating conditions.</param>
 /// <param name="verboseLog">Whether to enable verbose logging.</param>
 /// <param name="normaliseAssetName">Normalise an asset name.</param>
 /// <param name="language">The current language.</param>
 public PatchManager(IMonitor monitor, ConditionFactory conditionFactory, bool verboseLog, Func <string, string> normaliseAssetName, LocalizedContentManager.LanguageCode language)
 {
     this.Monitor            = monitor;
     this.ConditionFactory   = conditionFactory;
     this.ConditionContext   = conditionFactory.BuildContext(language);
     this.Verbose            = verboseLog;
     this.NormaliseAssetName = normaliseAssetName;
 }
        public void OrSymbol()
        {
            var context = new ConditionContext("||");

            ConditionParser.Tokenise(context);
            var value = Assert.Single(context.Values);

            Assert.IsType <Or>(value);
        }
        public void GreaterThanWord()
        {
            var context = new ConditionContext(" is greater than ");

            ConditionParser.Tokenise(context);
            var value = Assert.Single(context.Values);

            Assert.IsType <GreaterThan>(value);
        }
        public void EqualSymbol()
        {
            var context = new ConditionContext("==");

            ConditionParser.Tokenise(context);
            var value = Assert.Single(context.Values);

            Assert.IsType <Equal>(value);
        }
        public void LessThanSymbol()
        {
            var context = new ConditionContext("<");

            ConditionParser.Tokenise(context);
            var value = Assert.Single(context.Values);

            Assert.IsType <LessThan>(value);
        }
        public void NotEqualWord()
        {
            var context = new ConditionContext(" is not ");

            ConditionParser.Tokenise(context);
            var value = Assert.Single(context.Values);

            Assert.IsType <NotEqual>(value);
        }
        public void AndWord()
        {
            var context = new ConditionContext(" and ");

            ConditionParser.Tokenise(context);
            var value = Assert.Single(context.Values);

            Assert.IsType <And>(value);
        }
        public void LessThanEqualWord()
        {
            var context = new ConditionContext(" is less than or equal ");

            ConditionParser.Tokenise(context);
            var value = Assert.Single(context.Values);

            Assert.IsType <LessThanEqual>(value);
        }
Beispiel #17
0
        /// <summary>
        /// Tries the process.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <returns></returns>
        public bool TryExecute(RuleContext context)
        {
            // check if this rule should be run
            if (Action.IsMatch(context))
            {
                Manager.LogIf(context.LogLevel >= 2, "Rule Pattern Matched", context.LogCategory);
                bool     skipOrNext      = false;
                string[] conditionValues = new string[_conditions.Count];

                // test to make sure all conditions are met
                for (int i = 0; i < _conditions.Count; i++)
                {
                    ConditionContext conditionContext       = new ConditionContext(i, context, _conditions[i]);
                    bool             containsOrNext         = ConditionFlagsProcessor.HasOrNext(_conditions[i].Flags);
                    bool             previousContainsOrNext = ConditionFlagsProcessor.HasOrNext(_conditions[Math.Max(0, i - 1)].Flags);

                    if (skipOrNext && (previousContainsOrNext || containsOrNext))
                    {
                        continue;
                    }
                    else
                    {
                        skipOrNext = false;
                    }

                    // test the condition if it fails and then terminate
                    if (!_conditions[i].Evaluate(conditionContext))
                    {
                        if (containsOrNext)
                        {
                            continue;
                        }
                        else
                        {
                            return(false);
                        }
                    }
                    else if (containsOrNext)
                    {
                        skipOrNext = true;
                    }
                }

                // call an external method that might want to inherit from this rule implimentation
                OnExecuting(context);

                // process the substition for the pattern
                Action.Execute(context);

                // the pattern matched
                return(true);
            }

            // the pattern did not match
            return(false);
        }
		/// <summary>
		/// Evaluates the specified context.
		/// </summary>
		/// <param name="context">The context.</param>
		/// <returns>
		/// 	<see langword="true"/> if the specified log level is match; otherwise, <see langword="false"/>.
		/// </returns>
		public bool Evaluate(ConditionContext context)
		{
			string test = Test.GetValue(context);

			// get the pattern with out the special character
			string pattern = Pattern.ToString().Substring(1);

			bool comparison = String.Compare(test, pattern, ConditionFlagsProcessor.HasNoCase(context.ConditionFlags)) > 0;
			return Pattern.InvertMatch ? !comparison : comparison;
		}
Beispiel #19
0
            public override bool Equals(object obj)
            {
                ConditionContext that = obj as ConditionContext;

                if (ReferenceEquals(that, null))
                {
                    return(false);
                }
                return(EnumerableExtensions.AreEqual(this.blocks, that.blocks));
            }
Beispiel #20
0
            public ConditionContext GetParentContext()
            {
                if (blocks.Count == 1)
                {
                    return(null);
                }
                ConditionContext parent = new ConditionContext();

                parent.blocks.AddRange(blocks.Take(blocks.Count - 1));
                return(parent);
            }
Beispiel #21
0
        /// <summary>
        /// Evaluates the specified context.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <returns>
        ///     <see langword="true"/> if the specified log level is match; otherwise, <see langword="false"/>.
        /// </returns>
        public bool Evaluate(ConditionContext context)
        {
            string test = Test.GetValue(context);

            // get the pattern with out the special character
            string pattern = Pattern.ToString().Substring(1);

            bool comparison = String.Compare(test, pattern, ConditionFlagsProcessor.HasNoCase(context.ConditionFlags)) == 0;

            return(Pattern.InvertMatch ? !comparison : comparison);
        }
 private void SetSearch(FilterconditionContext filter, string name, string varName)
 {
     if (filter != null)
     {
         var dq = new DataCube(name, DataStatement.SEARCH, varName);
         ConditionContext condition = filter.condition();
         var search = new State.Search(condition.children[0].GetText(), condition.children[1].GetText(), condition.children[2].GetText());
         dq.SearchStatement = (search);
         DataCubes.Add(dq);
     }
 }
Beispiel #23
0
        private bool CheckCondition(ConditionContext condition)
        {
            ValidateChildCount(condition, 3);
            object result = Interpret(condition.GetChild(1));

            if (result is bool boolResult)
            {
                return(boolResult);
            }
            throw new InterpreterException(condition, "Condition should be evaluated to boolean, not " + result.GetType());
        }
Beispiel #24
0
        /// <summary>
        /// Determines whether the specified log level is match.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <returns>
        ///     <see langword="true"/> if the specified log level is match; otherwise, <see langword="false"/>.
        /// </returns>
        public bool Evaluate(ConditionContext context)
        {
            bool   isMatch = false;
            string test    = Test.GetValue(context);

            // pattern handles its own invert if needed
            isMatch = _pattern.IsMatch(test, context);

            Manager.LogIf(context.LogLevel >= 2, isMatch ? " Matched" : " Not Matched", context.LogCategory);
            return(isMatch);
        }
 public void TestPredicateCondition()
 {
     string newValue = "bcd";
     PropertyRule rule = PropertyRule.Create<TestModel, string>(e => e.StrProperty);
     Func<TestModel, bool> predicate = e => e.StrProperty != null;
     rule.AddCondition(new PredicateCondition(predicate.CoerceToNonGeneric()));
     rule.Assign(e => newValue);
     TestModel model = new TestModel();
     ConditionContext context = new ConditionContext(model);
     rule.Set(context);
     Assert.AreNotEqual(model.StrProperty, newValue);
 }
Beispiel #26
0
        /// <summary>
        /// Creates the condition execution context.
        /// </summary>
        /// <returns></returns>
        public ConditionContext CreateOutputConditionContext(Uri requestedUrl, byte[] responseContent)
        {
            // create properties
            var condition = new Mock <ICondition>().Object;

            // setup object
            var ruleContext      = CreateOutputRuleContext(requestedUrl, responseContent);
            var conditionContext = new ConditionContext(0, ruleContext, condition);

            // return object
            return(conditionContext);
        }
Beispiel #27
0
        /// <summary>
        /// Creates the condition execution context.
        /// </summary>
        /// <returns></returns>
        public ConditionContext CreateConditionContext(Uri requestedUrl)
        {
            // create properties
            var condition = new Mock <ICondition>().Object;

            // setup object
            var ruleContext      = CreateRuleContext(requestedUrl);
            var conditionContext = new ConditionContext(0, ruleContext, condition);

            // return object
            return(conditionContext);
        }
        public override Expression GetQueryExpression(ConditionContext p_Context)
        {
            StringOperatorCondition <T> p_Condition = this.Condition as StringOperatorCondition <T>;

            Assert.IsNotNull((object)p_Condition, "Condition has the wrong type. Type \"{0}\" is expected.", new object[1]
            {
                (object)typeof(StringOperatorCondition <T>).FullName
            });
            Expression expression;

            switch (p_Condition.OperatorId)
            {
            case "{2E67477C-440C-4BCA-A358-3D29AED89F47}":
                expression = this.HandleContains(p_Condition, p_Context);
                break;

            case "{22E1F05F-A17A-4D0C-B376-6F7661500F03}":
                expression = this.HandleEndsWith(p_Condition, p_Context);
                break;

            case "{10537C58-1684-4CAB-B4C0-40C10907CE31}":
                expression = this.HandleEquals(p_Condition, p_Context);
                break;

            case "{537244C2-3A3F-4B81-A6ED-02AF494C0563}":
                expression = this.HandleEqualsCaseInsensitive(p_Condition, p_Context);
                break;

            case "{F8641C26-EE27-483C-9FEA-35529ECC8541}":
                expression = this.HandleMatchRegex(p_Condition, p_Context);
                break;

            case "{A6AC5A6B-F409-48B0-ACE7-C3E8C5EC6406}":
                expression = this.HandleNotEqual(p_Condition, p_Context);
                break;

            case "{6A7294DF-ECAE-4D5F-A8D2-C69CB1161C09}":
                expression = this.HandleNotEqualCaseInsensitive(p_Condition, p_Context);
                break;

            case "{FDD7C6B1-622A-4362-9CFF-DDE9866C68EA}":
                expression = this.HandleStartsWith(p_Condition, p_Context);
                break;

            default:
                StringConditionWrapper <T, TCondition> .s_Logger.Debug(string.Format("Unknown operator id \"{0}\". Returning true expression.", (object)p_Condition.OperatorId));

                expression = (Expression)Expression.Constant((object)true);
                break;
            }
            return(expression);
        }
 public void TestMethod1()
 {
     string newValue = "bcd";
     PropertyRule rule = PropertyRule.Create<TestModel, string>(e => e.StrProperty);
     rule.Assign(e => newValue);
     TestModel model = new TestModel();
     ConditionContext context = new ConditionContext(model);
     rule.Set(context);
     Assert.AreEqual(model.StrProperty, newValue);
     //
     // TODO: Add test logic here
     //
 }
		/// <summary>
		/// Evaluates the specified context.
		/// </summary>
		/// <param name="context">The context.</param>
		/// <returns>
		/// 	<see langword="true"/> if the specified log level is match; otherwise, <see langword="false"/>.
		/// </returns>
		public bool Evaluate(ConditionContext context)
		{
			string test = Test.GetValue(context);

			if (String.IsNullOrEmpty(test))
				return false;

			if (!test.StartsWith(HttpRuntime.AppDomainAppPath) && !test.Contains(":"))
				test = context.HttpContext.Server.MapPath(test);

			bool exists = File.Exists(test);
			return Pattern.InvertMatch ? !exists : exists;
		}
        public void EqualityCheck()
        {
            var context = new ConditionContext("defeated == false");

            ConditionParser.Tokenise(context);
            Assert.Equal(3, context.Values.Count);

            var values = context.Values.ToList();

            Assert.IsType <LiteralValue>(values[0]);
            Assert.IsType <Equal>(values[1]);
            Assert.IsType <Variable>(values[2]);
        }
        public void MultipleChecksWithSymbols()
        {
            var context = new ConditionContext("defeated == false && 5 >= 3");

            ConditionParser.Tokenise(context);
            Assert.Equal(7, context.Values.Count);

            var values = context.Values.Reverse().ToList();

            Assert.IsType <Variable>(values[0]);
            Assert.IsType <Equal>(values[1]);
            Assert.IsType <LiteralValue>(values[2]);
            Assert.IsType <And>(values[3]);
            Assert.IsType <LiteralValue>(values[4]);
            Assert.IsType <GreaterThanEqual>(values[5]);
            Assert.IsType <LiteralValue>(values[6]);
        }
Beispiel #33
0
        public Expression <Func <T, bool> > GetQueryExpression <T, TK>(IEnumerable <ISearchCondition <TK> > conditions) where T : SearchResultItem where TK : RuleContext
        {
            Expression <Func <T, bool> > predicate = null;

            if (conditions.Any())
            {
                ParameterExpression expression = Expression.Parameter(typeof(T), "item");
                ConditionContext    context    = new ConditionContext(expression);
                foreach (ISearchCondition <TK> condition in conditions)
                {
                    Expression ruleExpression = condition.GetQueryExpression(context);
                    predicate = Expression.Lambda <Func <T, bool> >(ruleExpression, new[] { expression });
                }
            }

            return(predicate);
        }
Beispiel #34
0
        /*********
        ** Public methods
        *********/
        /// <summary>Update the patch data when the context changes.</summary>
        /// <param name="context">The condition context.</param>
        /// <returns>Returns whether the patch data changed.</returns>
        public virtual bool UpdateContext(ConditionContext context)
        {
            // update conditions
            bool conditionsChanged;
            {
                bool wasMatch = this.MatchesContext;
                this.MatchesContext = this.Conditions.Count == 0 || this.Conditions.Values.All(p => p.IsMatch(context));
                conditionsChanged   = wasMatch != this.MatchesContext;
            }

            // update asset name
            bool targetChanged = this.TokenableAssetName.UpdateContext(context);

            this.AssetName = this.NormaliseAssetName(this.TokenableAssetName.Value);

            return(conditionsChanged || targetChanged);
        }
        /// <summary>
        /// Evaluates the specified context.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <returns>
        /// 	<see langword="true"/> if the specified log level is match; otherwise, <see langword="false"/>.
        /// </returns>
        public bool Evaluate(ConditionContext context)
        {
            var test = Test.GetValue(context);

            if (String.IsNullOrEmpty(test))
            {
                return false;
            }

            if (!test.StartsWith(UrlRewriterManager.AppDomainAppPath) && !test.Contains(":"))
            {
                test = context.HttpContext.Server.MapPath(test);
            }

            var exists = File.Exists(test);
            return Pattern.InvertMatch ? !exists : exists;
        }
		/// <summary>
		/// Evaluates the specified context.
		/// </summary>
		/// <param name="context">The context.</param>
		/// <returns>
		/// 	<see langword="true"/> if the specified log level is match; otherwise, <see langword="false"/>.
		/// </returns>
		public bool Evaluate(ConditionContext context)
		{
			string test = Test.GetValue(context);

			if (String.IsNullOrEmpty(test))
				return IsMatch(false);

			if (!test.StartsWith(HttpRuntime.AppDomainAppPath) && !test.Contains(":"))
				test = context.HttpContext.Server.MapPath(test);

			if (File.Exists(test))
			{
				FileInfo file = new FileInfo(test);
				return IsMatch(file.Length > 0);
			}

			return IsMatch(false);
		}
        public Expression <Func <T, bool> > GetFilterExpression <T>(IEnumerable <string> values) where T : SearchResultItem
        {
            bool comparison = false;

            bool.TryParse(values.FirstOrDefault(), out comparison);

            if ((!InnerItem.Apply_When_True && comparison) || (!InnerItem.Apply_When_False && !comparison))
            {
                return(null);
            }

            ParameterExpression expression = Expression.Parameter(typeof(T), "item");
            ConditionContext    context    = new ConditionContext(expression);

            var equals = new Func <Expression, Expression, Expression>(Expression.Equal);

            return(Expression.Lambda <Func <T, bool> >((Expression)equals(Expression.Property(context.ParameterExpression, typeof(T), SearchResultItemUtil.GetPropertyName <T>(InnerItem.Field_Name)), Expression.Constant(comparison)), new[] { expression }));
        }
        /// <summary>
        /// Evaluates the specified context.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <returns>
        /// 	<see langword="true"/> if the specified log level is match; otherwise, <see langword="false"/>.
        /// </returns>
        public bool Evaluate(ConditionContext context)
        {
            var test = Test.GetValue(context);

            if (string.IsNullOrEmpty(test))
            {
                return IsMatch(false);
            }

            if (!test.StartsWith(UrlRewriterManager.AppDomainAppPath) && !test.Contains(":"))
            {
                test = context.HttpContext.Server.MapPath(test);
            }

            if (File.Exists(test))
            {
                var file = new FileInfo(test);
                return IsMatch(file.Length > 0);
            }

            return IsMatch(false);
        }
 public PropertyConditionContext(ConditionContext parentContext, PropertyRule rule, string propertyName)
 {
     ParentContext = parentContext;
     Rule = rule;
     PropertyName = propertyName;
 }
		/// <summary>
		/// Determines whether the specified log level is match.
		/// </summary>
		/// <param name="context">The context.</param>
		/// <returns>
		/// 	<see langword="true"/> if the specified log level is match; otherwise, <see langword="false"/>.
		/// </returns>
		public bool Evaluate(ConditionContext context)
		{
			bool isMatch = false;
			string test = Test.GetValue(context);

			// pattern handles its own invert if needed
			isMatch = _pattern.IsMatch(test, context);

			Manager.LogIf(context.LogLevel >= 2, isMatch ? " Matched" : " Not Matched", context.LogCategory);
			return isMatch;
		}
        /// <summary>
        /// Determines whether the specified log level is match.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <returns>
        /// 	<see langword="true"/> if the specified log level is match; otherwise, <see langword="false"/>.
        /// </returns>
        public bool Evaluate(ConditionContext context)
        {
            var test = Test.GetValue(context);

            // pattern handles its own invert if needed
            var isMatch = _pattern.IsMatch(test, context);

            Logger.InfoFormat(isMatch ? " Matched" : " Not Matched");

            return isMatch;
        }
 /// <summary>
 /// Gets the value.
 /// </summary>
 /// <param name="context">The context.</param>
 /// <returns></returns>
 public string GetValue(ConditionContext context)
 {
     return Pattern.Replace(_test, context);
 }
	public ConditionContext condition() {
		ConditionContext _localctx = new ConditionContext(Context, State);
		EnterRule(_localctx, 12, RULE_condition);
		try {
			EnterOuterAlt(_localctx, 1);
			{
			State = 114; _localctx.c = condition_h();
			State = 115; Match(Eof);
			 _localctx.value =  _localctx.c.value; 
			}
		}
		catch (RecognitionException re) {
			_localctx.exception = re;
			ErrorHandler.ReportError(this, re);
			ErrorHandler.Recover(this, re);
		}
		finally {
			ExitRule();
		}
		return _localctx;
	}
        /// <summary>
        /// Tries the process.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <returns></returns>
        public bool TryExecute(RuleContext context)
        {
            // check if this rule should be run
            if (Action.IsMatch(context))
            {
                Logger.Info("Rule Pattern Matched");

                var skipOrNext = false;
                var conditionValues = new string[_conditions.Count];

                // test to make sure all conditions are met
                for (var i = 0; i < _conditions.Count; i++)
                {
                    var conditionContext = new ConditionContext(i, context, _conditions[i]);
                    var containsOrNext = ConditionFlagsProcessor.HasOrNext(_conditions[i].Flags);
                    var previousContainsOrNext = ConditionFlagsProcessor.HasOrNext(_conditions[Math.Max(0, i - 1)].Flags);

                    if (skipOrNext && (previousContainsOrNext || containsOrNext))
                    {
                        continue;
                    }
                    skipOrNext = false;

                    // test the condition if it fails and then terminate
                    if (!_conditions[i].Evaluate(conditionContext))
                    {
                        if (containsOrNext)
                        {
                            continue;
                        }
                        return false;
                    }
                    else if (containsOrNext)
                    {
                        skipOrNext = true;
                    }
                }

                // call an external method that might want to inherit from this rule implimentation
                OnExecuting(context);

                // process the substition for the pattern
                Action.Execute(context);

                // the pattern matched
                return true;
            }

            // the pattern did not match
            return false;
        }
		/// <summary>
		/// Creates the condition execution context.
		/// </summary>
		/// <returns></returns>
		public ConditionContext CreateOutputConditionContext(Uri requestedUrl, byte[] responseContent)
		{
			// create properties
			var condition = new Mock<ICondition>().Object;

			// setup object
			var ruleContext = CreateOutputRuleContext(requestedUrl, responseContent);
			var conditionContext = new ConditionContext(0, ruleContext, condition);

			// return object
			return conditionContext;
		}
		/// <summary>
		/// Creates the condition execution context.
		/// </summary>
		/// <returns></returns>
		public ConditionContext CreateConditionContext(Uri requestedUrl)
		{
			// create properties
			var condition = new Mock<ICondition>().Object;

			// setup object
			var ruleContext = CreateRuleContext(requestedUrl);
			var conditionContext = new ConditionContext(0, ruleContext, condition);

			// return object
			return conditionContext;
		}