示例#1
0
        /// <summary>
        ///     Evaluates the rule and its sub rules
        /// </summary>
        /// <param name="runner"></param>
        /// <param name="priority">the priority level : a rule can be activated only if its priority level == priority</param>
        /// <param name="instance">The instance on which the rule must be evaluated</param>
        /// <param name="ruleConditions">the rule conditions to be activated</param>
        /// <param name="explanation">The explanation part to be filled</param>
        /// <param name="runner"></param>
        /// <returns>the number of actions that were activated during this evaluation</returns>
        public bool Evaluate(Runner runner, acceptor.RulePriority?priority, IModelElement instance,
                             HashSet <Activation> activations, ExplanationPart explanation)
        {
            bool retVal = false;

            ExplanationPart       conditionExplanation = ExplanationPart.CreateSubExplanation(explanation, this);
            InterpretationContext context = new InterpretationContext(instance);

            retVal = EvaluatePreConditions(context, conditionExplanation, runner);

            if (retVal)
            {
                if (conditionExplanation != null)
                {
                    conditionExplanation.Message = "Condition " + Name + " satisfied";
                }

                foreach (Rule subRule in SubRules)
                {
                    subRule.Evaluate(runner, priority, instance, activations, conditionExplanation);
                }

                if (priority == null || EnclosingRule.getPriority() == priority)
                {
                    activations.Add(new Activation(this, instance, conditionExplanation));
                }
            }
            else
            {
                if (conditionExplanation != null)
                {
                    conditionExplanation.Message = "Condition " + Name + " not satisfied";
                }
            }


            return(retVal);
        }
示例#2
0
        /// <summary>
        /// Evaluates the rule and its sub rules
        /// </summary>
        /// <param name="runner"></param>
        /// <param name="priority">the priority level : a rule can be activated only if its priority level == priority</param>
        /// <param name="instance">The instance on which the rule must be evaluated</param>
        /// <param name="ruleConditions">the rule conditions to be activated</param>
        /// <returns>the number of actions that were activated during this evaluation</returns>
        public bool Evaluate(Tests.Runner.Runner runner, Generated.acceptor.RulePriority priority, Utils.IModelElement instance, List <RuleCondition> ruleConditions)
        {
            bool retVal = false;

            Interpreter.InterpretationContext context = new Interpreter.InterpretationContext(instance);
            retVal = EvaluatePreConditions(context);

            if (retVal)
            {
                foreach (Rule subRule in SubRules)
                {
                    subRule.Evaluate(runner, priority, instance, ruleConditions);
                }

                if (EnclosingRule.getPriority() == priority)
                {
                    ruleConditions.Add(this);
                }
            }


            return(retVal);
        }