Esempio n. 1
0
        internal IEnumerable <WorkflowDecision> Decisions(IWorkflowHistoryEvents historyEvents)
        {
            _generatedActions = new WorkflowActions();
            _executingEvents  = new Stack <WorkflowEvent>();
            IWorkflow workflow  = this;
            var       decisions = new List <WorkflowDecision>();

            try
            {
                _currentWorkflowHistoryEvents = historyEvents;
                BeforeExecution();
                foreach (var workflowEvent in historyEvents.NewEvents())
                {
                    workflow.PushNewExecutingEvent(workflowEvent);

                    try
                    {
                        var action = workflowEvent.Interpret(this) ?? WorkflowAction.Empty;
                        _generatedActions.Add(action);
                        decisions.AddRange(action.Decisions(this));
                    }
                    finally
                    {
                        workflow.PopExecutingEvent();
                    }
                }

                return(decisions.Distinct().CompatibleDecisions(this).Where(d => d != WorkflowDecision.Empty).ToArray());
            }
            finally
            {
                //Following line may not be required because clean up has handled before it comes here.
                _allWorkflowItems.ResetContinueItems();

                AfterExecution();
                _executingEvents = new Stack <WorkflowEvent>();
                _currentWorkflowHistoryEvents = null;
            }
        }