Beispiel #1
0
 private void OnNewState(State newState)
 {
     if (NewState != null)
     {
         NewState(this, new EventArgs<State>(newState));
     }
 }
Beispiel #2
0
        public StateMachine(State initialState, IEnumerable inputAlphabet)
        {
            this.initialState = initialState;

            this.inputAlphabet = new ArrayList();

            foreach (object o in inputAlphabet)
            {
                this.inputAlphabet.Add(o);
            }
        }
 private void OnStateWaitingForInput(State state)
 {
     if (this.syncContext != null && this.syncContext.InvokeRequired)
     {
         this.syncContext.BeginInvoke(new Procedure<State>(OnStateWaitingForInput), new object[] { state });
     }
     else
     {
         if (StateWaitingForInput != null)
         {
             StateWaitingForInput(this, new EventArgs<State>(state));
         }
     }
 }
Beispiel #4
0
        private void SetCurrentState(State newState)
        {
            if (this.currentState != null && this.currentState.IsFinalState)
            {
                throw new InvalidOperationException("state machine is already in a final state");
            }

            this.currentState = newState;
            this.currentState.StateMachine = this;
            OnNewState(this.currentState);
            this.currentState.OnEnteredState();

            if (!this.currentState.IsFinalState)
            {
                ProcessQueuedInput();
            }
        }
Beispiel #5
0
 public override void ProcessInput(object input, out State newState)
 {
     if (input.Equals(PrivateInput.GoToReadyToInstall))
     {
         newState = new ReadyToInstallState(this.installerPath, this.newVersionInfo);
     }
     else if (input.Equals(PrivateInput.GoToError))
     {
         string errorMessage = PdnResources.GetString("Updates.ExtractingState.GenericError");
         newState = new ErrorState(this.exception, errorMessage);
     }
     else if (input.Equals(PrivateInput.GoToAborted))
     {
         newState = new AbortedState();
     }
     else
     {
         throw new ArgumentException();
     }
 }
Beispiel #6
0
 public abstract void ProcessInput(object input, out State newState);
Beispiel #7
0
        public override void ProcessInput(object input, out State newState)
        {
            if (input.Equals(PrivateInput.GoToExtracting))
            {
                newState = new ExtractingState(this.zipTempName, this.downloadMe);
            }
            else if (input.Equals(PrivateInput.GoToError))
            {
                string errorMessage;

                if (this.exception is WebException)
                {
                    errorMessage = Utility.WebExceptionToErrorMessage((WebException)this.exception);
                }
                else
                {
                    errorMessage = PdnResources.GetString("Updates.DownloadingState.GenericError");
                }

                newState = new ErrorState(this.exception, errorMessage);
            }
            else if (input.Equals(PrivateInput.GoToAborted))
            {
                newState = new AbortedState();
            }
            else
            {
                throw new ArgumentException();
            }
        }