예제 #1
0
        public void Run()
        {
            var currentDirection = 0;
            var currentIndex     = 0;

            while (currentIndex < steps.Count)
            {
                PreviousStep = currentIndex > 0 ? steps[currentIndex - 1] : null;
                CurrentStep  = steps[currentIndex];

                var result = CurrentStep.Run(this);
                switch (result)
                {
                case IStepResult.Next:
                    currentDirection = 1;
                    break;

                case IStepResult.Previous:
                    currentDirection = -1;
                    break;

                case IStepResult.Skip:
                    // do not change direction
                    break;

                default:
                    IsCancelled = true;
                    return;
                }

                currentIndex += currentDirection;
            }
        }
예제 #2
0
            private bool Run(List <String> stepNameAlreadyCalled)
            {
                if (CurrentStep == null)
                {
                    return(true);
                }
                if (stepNameAlreadyCalled.Contains(CurrentStep.Name))
                {
                    return(false);
                }
                bool isStepEnd = CurrentStep.Run(FirstCallCurrentStep);

                if (isStepEnd)
                {
                    // To avoid forever loop
                    stepNameAlreadyCalled.Add(CurrentStep.Name);
                    FirstCallCurrentStep = true;
                    CurrentStep          = CurrentStep.NextStep;
                    if (CurrentStep != null && CurrentStep.IsImmediateRun)
                    {
                        return(Run(stepNameAlreadyCalled));
                    }
                }
                else
                {
                    FirstCallCurrentStep = false;
                }
                return(false);
            }