public void Rollback() { if (_memento != null) { _settings.RestoreFromMemento(_memento); } else { throw new InvalidOperationException("The presenter must be initalized before you can call Rollback"); } }
private ISettingsOriginator RestoreFromParameters(string parameters) { //Restore our saved memento ISettingsMemento memento = _kernel.Get <ISettingsMemento>(new ConstructorArgument("settingsAsString", parameters)); //Restore originator from memento ISettingsOriginator originator = SettingsOriginatorFactory.Instance.CreateOriginator(); originator.RestoreFromMemento(memento); return(originator); }
private ISettingsOriginator RestoreFromCurrentUserSettings() { //Grab settings as string ISettingsService svc = _kernel.Get <ISettingsService>(); //Restore our saved memento ISettingsMemento memento = _kernel.Get <ISettingsMemento>(new ConstructorArgument("settingsAsString", svc.GetAllSettingsAsXML())); //Restore originator from memento ISettingsOriginator originator = SettingsOriginatorFactory.Instance.CreateOriginator(); originator.RestoreFromMemento(memento); return(originator); }