public void RestoreFromMemento(IMemento m) { if (!m.GetType().Equals(typeof(NullMemento))) { InternalState = m.GetState(); } }
public void Restore(IMemento memento) { if (memento is not BalanceMemento) { throw new UnknownMementoClassException(memento.ToString()); } Balance = memento.GetState(); }
public void Restore(IMemento memento) { if (!(memento is ConcreteMemento)) { throw new Exception("Unknown memento class"); } this._cities = memento.GetState(); }
public void Restore(IMemento memento) { if (!(memento is ConcreteMemento)) { throw new ArgumentException("Unknown memento class: " + memento.GetType().Name); } _state = memento.GetState(); }
// 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(); }
public bool Restore(IMemento memento) { if (!(memento is OriginatorMemento)) { return(false); } state = memento.GetState(); return(true); }
// Восстанавливает состояние Создателя из объекта снимка. public void Restore(IMemento memento) { if (!(memento is ConcreteMemento)) { throw new Exception("Неизвестный снимок " + memento.ToString()); } this._state = memento.GetState(); Console.WriteLine($"Текущее состояние: {_state}"); }
// 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}"); }
// 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}"); }
// 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}"); }
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(); }
// 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}"); }
//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}"); }
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)); } }
public void Restore(IMemento memento) { _map = memento.GetState(); }
public void Restore(IMemento memento) { _state = memento.GetState().ToList(); }
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(); }