コード例 #1
0
 public void Rollback()
 {
     if (_memento != null)
     {
         _settings.RestoreFromMemento(_memento);
     }
     else
     {
         throw new InvalidOperationException("The presenter must be initalized before you can call Rollback");
     }
 }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }