Beispiel #1
0
        public int Fire(int maxRulesNumber, CancellationToken cancellationToken)
        {
            int ruleFiredCount = 0;

            while (!_agenda.IsEmpty && ruleFiredCount < maxRulesNumber)
            {
                Activation     activation    = _agenda.Pop();
                IActionContext actionContext = new ActionContext(this, activation, cancellationToken);

                try
                {
                    _actionExecutor.Execute(_executionContext, actionContext);
                }
                finally
                {
                    ruleFiredCount++;
                    if (AutoPropagateLinkedFacts)
                    {
                        PropagateLinked();
                    }
                }

                if (actionContext.IsHalted || cancellationToken.IsCancellationRequested)
                {
                    break;
                }
            }
            return(ruleFiredCount);
        }
Beispiel #2
0
        public int Fire(int maxRulesNumber)
        {
            int ruleFiredCount = 0;

            while (!_agenda.IsEmpty() && ruleFiredCount < maxRulesNumber)
            {
                Activation     activation    = _agenda.Pop();
                IActionContext actionContext = new ActionContext(this, activation);

                _actionExecutor.Execute(_executionContext, actionContext);

                ruleFiredCount++;
                if (actionContext.IsHalted)
                {
                    break;
                }
            }
            return(ruleFiredCount);
        }