Beispiel #1
0
 public bool Exists(string Name)
 {
     using (ReadWriteLock ReadWriteLock1 = new ReadWriteLock(this.readerWriterLockSlim, ReadWriteMode.Read))
     {
         return(this.ExeConfiguration.AppSettings.Settings.AllKeys.Contains(Name));
     }
 }
Beispiel #2
0
 public void Delete(string Name)
 {
     using (ReadWriteLock ReadWriteLock1 = new ReadWriteLock(this.readerWriterLockSlim, ReadWriteMode.Write))
     {
         if (this.ExeConfiguration.AppSettings.Settings.AllKeys.Contains(Name))
         {
             this.ExeConfiguration.AppSettings.Settings.Remove(Name);
             this.ExeConfiguration.Save(ConfigurationSaveMode.Modified);
             System.Configuration.ConfigurationManager.RefreshSection("appSettings");
         }
     }
 }
Beispiel #3
0
 public string GetValue(string Name, string DefaultValue)
 {
     using (ReadWriteLock ReadWriteLock1 = new ReadWriteLock(this.readerWriterLockSlim, ReadWriteMode.Read))
     {
         if (this.ExeConfiguration.AppSettings.Settings.AllKeys.Contains(Name))
         {
             return(this.ExeConfiguration.AppSettings.Settings[Name].Value);
         }
         else
         {
             return(DefaultValue);
         }
     }
 }
Beispiel #4
0
        public void SetValue(string Name, string Value)
        {
            using (ReadWriteLock ReadWriteLock1 = new ReadWriteLock(this.readerWriterLockSlim, ReadWriteMode.Write))
            {
                if (this.ExeConfiguration.AppSettings.Settings.AllKeys.Contains(Name))
                {
                    this.ExeConfiguration.AppSettings.Settings[Name].Value = Value;
                }
                else
                {
                    this.ExeConfiguration.AppSettings.Settings.Add(Name, Value);
                }

                this.ExeConfiguration.Save(ConfigurationSaveMode.Modified);
                System.Configuration.ConfigurationManager.RefreshSection("appSettings");
            }
        }