示例#1
0
        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();
        }
示例#2
0
        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);
        }
示例#3
0
 public BaseStateMachine()
 {
     this.CurrentState = BaseState.NullObject();
     this.states       = new List <BaseState>();
     this.machineState = BaseStateMachine.StateMachineState.Stopped;
 }
示例#4
0
		public BaseStateMachine()
		{
			this.CurrentState = BaseState.NullObject();
			this.states = new List<BaseState>();
			this.machineState = BaseStateMachine.StateMachineState.Stopped;
		}
示例#5
0
		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;
		}
示例#6
0
		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();
		}