예제 #1
0
        private void ExecuteThenClause(IRuleEngineContext ruleEngineContext)
        {
            var propertyValue = PropertyValueDelegate.DynamicInvoke(ruleEngineContext.Subject) as IEnumerable;

            if (propertyValue != null)
            {
                foreach (var childSubject in propertyValue)
                {
                    var subContext = new RuleEngineContext(
                        childSubject, ruleEngineContext.RuleViolationReporter, _ruleSelector, ruleEngineContext.NameProvider, ruleEngineContext);
                    _executeRules(subContext);
                }
            }
        }
예제 #2
0
        private bool ExecuteWhenClause(IRuleEngineContext context)
        {
            var whenClauseResult = true;

            var propertyValue     = PropertyValueDelegate.DynamicInvoke(context.Subject);
            var failedConstraints = new List <IConstraint> ();

            context.WorkingMemory.AddContextObject(failedConstraints, Name);
            foreach (var constraint in Constraints)
            {
                var constraintIsCompliant = constraint.IsCompliant(propertyValue, context);
                if (!constraintIsCompliant)
                {
                    whenClauseResult = false;
                    failedConstraints.Add(constraint);
                }
            }

            return(whenClauseResult);
        }