private void SetErrorState(Error error)
        {
            if (!this.CheckIsRunning())
            {
                return;
            }
            if (this.IsCurrentStateEndErrorState())
            {
                this.StopStateMachine();
                this.RaiseStateMachineErroredEvent(error);
                return;
            }
            BaseErrorState baseErrorState = this.CurrentState.NextErrorState(error);

            if (baseErrorState != this.CurrentState)
            {
                this.CurrentState.Stop();
                this.CurrentState.Finished -= new EventHandler <TransitionEventArgs>(this.CurrentStateFinished);
                this.CurrentState.Errored  -= new EventHandler <Error>(this.CurrentStateErrored);
                this.CurrentState           = baseErrorState;
                baseErrorState.Finished    += new EventHandler <TransitionEventArgs>(this.CurrentStateFinished);
                baseErrorState.Errored     += new EventHandler <Error>(this.CurrentStateErrored);
                baseErrorState.Start(error);
            }
        }
Exemple #2
0
        private BaseState HandleTransitionException(BaseState state, Exception exception)
        {
            Error          error          = new Error(exception);
            BaseErrorState baseErrorState = this.NextErrorState(error);

            if (baseErrorState != null)
            {
                baseErrorState.Start(error);
                state = baseErrorState;
            }
            return(state);
        }