Exemple #1
0
 public void RestoreFromMemento(IMemento m)
 {
     if (!m.GetType().Equals(typeof(NullMemento)))
     {
         InternalState = m.GetState();
     }
 }
Exemple #2
0
 public void Restore(IMemento memento)
 {
     if (memento is not BalanceMemento)
     {
         throw new UnknownMementoClassException(memento.ToString());
     }
     Balance = memento.GetState();
 }
Exemple #3
0
        public void Restore(IMemento memento)
        {
            if (!(memento is ConcreteMemento))
            {
                throw new Exception("Unknown memento class");
            }

            this._cities = memento.GetState();
        }
Exemple #4
0
        public void Restore(IMemento memento)
        {
            if (!(memento is ConcreteMemento))
            {
                throw new ArgumentException("Unknown memento class: " + memento.GetType().Name);
            }

            _state = memento.GetState();
        }
Exemple #5
0
        // Restores the Originator's state from a memento object.
        public void Restore(IMemento memento)
        {
            if (!(memento is ConcreteMemento))
            {
                throw new Exception("Unknown memento class " + memento.ToString());
            }

            this.state = memento.GetState();
        }
        /// <summary>
        /// Restores the Originator's state from a memento object
        /// </summary>
        /// <param name="memento">Memento hold the state which is need to be restored</param>
        public void Restore(IMemento memento)
        {
            // Throw exception if memento is not the current memento's type
            if (!(memento is ConcreteMementoA))
            {
                throw new Exception($"Unknown memento class { memento.ToString() }");
            }

            _currentState = memento.GetState();
        }
Exemple #7
0
        public bool Restore(IMemento memento)
        {
            if (!(memento is OriginatorMemento))
            {
                return(false);
            }

            state = memento.GetState();
            return(true);
        }
Exemple #8
0
        // Восстанавливает состояние Создателя из объекта снимка.
        public void Restore(IMemento memento)
        {
            if (!(memento is ConcreteMemento))
            {
                throw new Exception("Неизвестный снимок " + memento.ToString());
            }

            this._state = memento.GetState();
            Console.WriteLine($"Текущее состояние: {_state}");
        }
Exemple #9
0
        // Restaura el estado del Originator a partir de un objeto memento.
        public void Restore(IMemento memento)
        {
            if (!(memento is ConcreteMemento))
            {
                throw new Exception("Clase memento desconocida " + memento.ToString());
            }

            _state = memento.GetState();
            Console.WriteLine($"Originator: Mi estado ha cambiado a: {_state}");
        }
Exemple #10
0
        // Restaura o estado do Originador a partir de um objeto memento.
        public void Restore(IMemento memento)
        {
            if (!(memento is ConcreteMemento))
            {
                throw new Exception("Classe de memento desconhecida " + memento.ToString());
            }

            this._state = memento.GetState();
            Console.Write($"Originador: Meu estado mudou para {_state}");
        }
        // Восстанавливает состояние Создателя из объекта снимка.
        public void Restore(IMemento memento)
        {
            if (!(memento is ConcreteMemento))
            {
                throw new Exception("Unknown memento class " + memento.ToString());
            }

            this._state = memento.GetState();
            Console.Write($"Originator: My state has changed to: {_state}");
        }
Exemple #12
0
        // Restores the Originator's state from a memento object.
        public void Restore(IMemento memento)
        {
            if (!(memento is ConcreteMemento))
            {
                throw new Exception("Unknown memento class " + memento);
            }

            _state = memento.GetState().ToString();
            _outputHelper.WriteLine($"Originator: My state has changed to: {_state}");
        }
Exemple #13
0
        public void Restore(IMemento memento)
        {
            if (!(memento is ConcreteGameLevel))
            {
                throw new Exception("Unknown memento class " + memento.ToString());
            }

            this._gameState = memento.GetState();
            Console.Write($"Notification: Time of the game has changed to: {_gameState}");
        }
        public void Restore(IMemento memento)
        {
            if (!(memento is ConcreteMemento))
            {
                throw new InvalidMementoException();
            }

            this.IsRestored           = true;
            this.CurrentEditorContent = memento.GetState();
        }
Exemple #15
0
        // Restores the Originator's state from a memento object.
        public void Restore(IMemento memento)
        {
            if (!(memento is ConcreteMemento))
            {
                throw new Exception("Unknown memento class " + memento.ToString());
            }
            double prevBalance = _state.money;

            _state = memento.GetState();
            Console.WriteLine($"Bank account balance was {prevBalance}. It has changed to: {_state.money}");
        }
Exemple #16
0
        //Restores the Originator's stanje from a memento object.
        public void Restore(IMemento memento)
        {
            if (!(memento is ConcreteMemento))
            {
                throw new Exception("Unknown memento class " + memento.ToString());
            }

            this._stanje = memento.GetState();
            SingletonTvKuca.Instanca.SetRasporedPrograma(this._stanje);
            Console.Write($"Originator: My stanje has changed to: {_stanje}");
        }
Exemple #17
0
        public void SetMemento(IMemento memento)
        {
            this.State      = memento.GetState();
            this.TypeOfPlay = (TypeOfPlay)State.TypeOfPlay;

            this.CreatePlaylist(this.TypeOfPlay);

            if (string.IsNullOrEmpty(State.SongFilePath) == false)
            {
                this.CurrentSong = Songs.FirstOrDefault(item => item.FilePath == State.SongFilePath);

                mediaPlayer.Open(new Uri(this.CurrentSong.FilePath));
                AddSongToHistory(CurrentSong);
                mediaPlayer.MediaOpened += MediaPlayer_MediaOpened;
            }
        }
        private void Read()
        {
            FileInfo fileInfo = new FileInfo("data.xml");

            if (!fileInfo.Exists)
            {
                return;
            }

            FileStream fileStream = null;

            IMemento memento = null;

            try
            {
                BinaryFormatter binaryFormatter = new BinaryFormatter();
                fileStream = new FileStream("data.xml", FileMode.OpenOrCreate);
                memento    = (MementoOfState)binaryFormatter.Deserialize(fileStream);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            finally
            {
                if (fileStream != null)
                {
                    fileStream.Close();
                }
            }

            if (memento != null)
            {
                this.folerPath = memento.GetState().FolderPath;

                if (string.IsNullOrEmpty(this.folerPath))
                {
                    return;
                }

                try
                {
                    List <string> files = Directory.GetFiles(this.folerPath, "*.mp3").ToList();
                    Player.Instance.LoadSongs(files, this.folerPath);
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                }

                RaisePropertyChanged(nameof(this.IsFilesLoaded));

                Player.Instance.SetMemento(memento);

                switch (Player.Instance.TypeOfPlay)
                {
                case TypeOfPlay.Normal:
                    this._playNormal   = true;
                    this._playRandom   = false;
                    this._playReversed = false;
                    break;

                case TypeOfPlay.Random:
                    this._playNormal   = false;
                    this._playRandom   = true;
                    this._playReversed = false;
                    break;

                case TypeOfPlay.Reversed:
                    this._playNormal   = false;
                    this._playRandom   = false;
                    this._playReversed = true;
                    break;

                default:
                    break;
                }

                RaisePropertyChanged(nameof(this.PlayNormal));
                RaisePropertyChanged(nameof(this.PlayRandom));
                RaisePropertyChanged(nameof(this.PlayReversed));
            }
        }
Exemple #19
0
 public void Restore(IMemento memento)
 {
     _map = memento.GetState();
 }
Exemple #20
0
 public void Restore(IMemento memento)
 {
     _state = memento.GetState().ToList();
 }
Exemple #21
0
 public void Restore(IMemento memento)
 {
     expression = memento.GetState();
 }
 public void Restore(IMemento memento)
 {
     _state = memento.GetState();
     PrintStateChange(nameof(Restore), null);
 }
 public void Restore(IMemento memento)
 {
     this.state = memento.GetState();
 }