Inheritance: ISetting
コード例 #1
0
 public void RestoreFromMemento(ISettingsMemento memento)
 {
     _settings.Clear();
     foreach (ISetting setting in memento.Settings)
     {
         ISetting newSetting = new Setting() { Name = setting.Name };
         if (setting.Encrypt & !String.IsNullOrEmpty(setting.Value))
             newSetting.Value = DecryptFromBase64(setting.Value);
         else
             newSetting.Value = setting.Value;
         _settings.Add(newSetting);
     }//end foreach
 }
コード例 #2
0
        public ISettingsMemento GetMemento()
        {
            List<ISetting> encryptedSettings = new List<ISetting>(_settings.Count);
            foreach (ISetting setting in _settings)
            {
                ISetting newSetting = new Setting() { Name = setting.Name, Encrypt = setting.Encrypt };
                if (setting.Encrypt && !String.IsNullOrEmpty(setting.Value))
                    newSetting.Value = EncryptAsBase64(setting.Value);
                else
                    newSetting.Value = setting.Value;
                encryptedSettings.Add(newSetting);
            }//end foreach

            return new XMLSettingsMemento(encryptedSettings);
        }