private void StartStateMachine() { if (this.states.Count == 0) { UnexpectedErrorException ex = new UnexpectedErrorException("No states to run state machine!"); Tracer <BaseStateMachine> .WriteError(ex); throw ex; } this.machineState = BaseStateMachine.StateMachineState.Running; this.CurrentState = this.states[0]; this.CurrentState.Finished += new EventHandler <TransitionEventArgs>(this.CurrentStateFinished); this.CurrentState.Errored += new EventHandler <Error>(this.CurrentStateErrored); this.CurrentState.Start(); }
private string StopStateMachine() { this.machineState = BaseStateMachine.StateMachineState.Stopped; string result = string.Empty; EndState endState = this.CurrentState as EndState; if (endState != null) { result = endState.Status; } this.CurrentState.Finished -= new EventHandler <TransitionEventArgs>(this.CurrentStateFinished); this.CurrentState.Errored -= new EventHandler <Error>(this.CurrentStateErrored); this.CurrentState.Stop(); this.CurrentState = BaseState.NullObject(); return(result); }
public BaseStateMachine() { this.CurrentState = BaseState.NullObject(); this.states = new List <BaseState>(); this.machineState = BaseStateMachine.StateMachineState.Stopped; }
public BaseStateMachine() { this.CurrentState = BaseState.NullObject(); this.states = new List<BaseState>(); this.machineState = BaseStateMachine.StateMachineState.Stopped; }
private string StopStateMachine() { this.machineState = BaseStateMachine.StateMachineState.Stopped; string result = string.Empty; EndState endState = this.CurrentState as EndState; if (endState != null) { result = endState.Status; } this.CurrentState.Finished -= new EventHandler<TransitionEventArgs>(this.CurrentStateFinished); this.CurrentState.Errored -= new EventHandler<Error>(this.CurrentStateErrored); this.CurrentState.Stop(); this.CurrentState = BaseState.NullObject(); return result; }
private void StartStateMachine() { if (this.states.Count == 0) { UnexpectedErrorException ex = new UnexpectedErrorException("No states to run state machine!"); Tracer<BaseStateMachine>.WriteError(ex); throw ex; } this.machineState = BaseStateMachine.StateMachineState.Running; this.CurrentState = this.states[0]; this.CurrentState.Finished += new EventHandler<TransitionEventArgs>(this.CurrentStateFinished); this.CurrentState.Errored += new EventHandler<Error>(this.CurrentStateErrored); this.CurrentState.Start(); }