Example #1
0
 public void SetValue(string name, string value, string defaultValue, PreferenceEncryption encryption)
 {
     if ((name == null) || (name.Length == 0))
     {
         throw new ArgumentException();
     }
     if (value == defaultValue)
     {
         if (!this.IsEmpty)
         {
             this._store.Remove(name);
         }
     }
     else
     {
         if (value == null)
         {
             throw new ArgumentNullException();
         }
         if (encryption == PreferenceEncryption.CurrentUser)
         {
             value = DataProtection.EncryptUserData(value);
         }
         else
         {
             value = DataProtection.EncryptData(value);
         }
         this.Store[name] = value;
     }
 }
Example #2
0
 public string GetValue(string name, string defaultValue, PreferenceEncryption encryption)
 {
     string data = this.GetValue(name, (string) null);
     if (data == null)
     {
         return defaultValue;
     }
     if (data.Length == 0)
     {
         return data;
     }
     try
     {
         if (encryption == PreferenceEncryption.CurrentUser)
         {
             return DataProtection.DecryptUserData(data);
         }
         return DataProtection.DecryptData(data);
     }
     catch (Exception)
     {
         return defaultValue;
     }
 }