Ejemplo n.º 1
0
        /// <summary>
        /// Check for disconnects between states and transitions.
        /// </summary>
        /// <returns>
        /// A <see cref="WorkflowAnalysis"/> object containing counters
        /// and information about errors found during analysis.
        /// </returns>
        public WorkflowAnalysis Analyze()
        {
            var res           = new WorkflowAnalysis();
            var visitedStates = new List <WorkflowState>();

            this.Analyze(this.InitialState, visitedStates, res);
            return(res);
        }
Ejemplo n.º 2
0
        private void Analyze(WorkflowState workflowState, ICollection <WorkflowState> visitedStates, WorkflowAnalysis res)
        {
            if (visitedStates.Contains(workflowState))
            {
                return;
            }

            visitedStates.Add(workflowState);
            res.StateCount = res.StateCount + 1;

            foreach (var transition in workflowState.Transitions)
            {
                res.TransitionCount = res.TransitionCount + 1;

                var toState = this.FindStateByName(transition.ToStateName);
                if (toState == null)
                {
                    res.AddError(new StateNotFoundException(this, transition.ToStateName));
                }
                else
                {
                    this.Analyze(toState, visitedStates, res);
                }
            }
        }