Example #1
0
        public String Get(Configuration.ConfFolder folder, Configuration.ConfEntry entry, String defaultValue)
        {
            String result = defaultValue;
            try
            {
                using (RegistryKey regkey = this.basekey.CreateSubKey(folder.ToString()))
                {
                    object o;
                    if ((o = regkey.GetValue(entry.ToString(), defaultValue)) != null)
                    {
                        if (!String.IsNullOrEmpty(o.ToString()))
                        {
                            result = o.ToString();
                        }
                    }
                    regkey.Close();
                }
            }
            catch (Exception e)
            {
                LOG.Error("Failed to get value from registry", e);
            }

            return result;
        }
Example #2
0
 public int Get(Configuration.ConfFolder folder, Configuration.ConfEntry entry, int defaultValue)
 {
     lock (this)
     {
         if (mDeferredSaveTimer.IsEnabled)
         {
             this.ImmediateSave();
         }
         int value;
         if (!IsolatedStorageSettings.ApplicationSettings.TryGetValue(BuildKey(folder, entry), out value))
         {
             value = defaultValue;
         }
         return value;
     }
 }
Example #3
0
 String BuildKey(Configuration.ConfFolder folder, Configuration.ConfEntry entry)
 {
     return String.Format("{0}/{1}", folder, entry);
 }
Example #4
0
 public bool Set(Configuration.ConfFolder folder, Configuration.ConfEntry entry, bool value)
 {
     return InternalSet(folder, entry, value);
 }
Example #5
0
        public bool InternalSet(Configuration.ConfFolder folder, Configuration.ConfEntry entry, object value)
        {
            lock (this)
            {
                IsolatedStorageSettings.ApplicationSettings[BuildKey(folder, entry)] = value;
                EventHandlerTrigger.TriggerEvent<ConfigurationEventArgs>(this.onConfigurationEvent, this, new ConfigurationEventArgs(folder, entry, value));

                this.DeferredSave();
                return true;
            }
        }
Example #6
0
 public int Get(Configuration.ConfFolder folder, Configuration.ConfEntry entry, int defaultValue)
 {
     int result = defaultValue;
     String value = this.Get(folder, entry, defaultValue.ToString());
     if (Int32.TryParse(value, out result))
     {
         return result;
     }
     return defaultValue;
 }
Example #7
0
 public bool Set(Configuration.ConfFolder folder, Configuration.ConfEntry entry, bool value)
 {
     return this.Set(folder, entry, value ? Boolean.TrueString : Boolean.FalseString);
 }
Example #8
0
 public bool Set(Configuration.ConfFolder folder, Configuration.ConfEntry entry, int value)
 {
     return this.Set(folder, entry, value.ToString());
 }
Example #9
0
        public bool Set(Configuration.ConfFolder folder, Configuration.ConfEntry entry, String value)
        {
            if (value == null)
            {
                return false;
            }

            try
            {
                using (RegistryKey regkey = this.basekey.CreateSubKey(folder.ToString()))
                {
                    regkey.SetValue(entry.ToString(), value);
                    regkey.Close();
                }
            }
            catch (Exception e)
            {
                LOG.Error("Failed to set value into registry", e);
                return false;
            }

            // Trigger
            EventHandlerTrigger.TriggerEvent<ConfigurationEventArgs>(this.onConfigurationEvent, this, new ConfigurationEventArgs(folder, entry, value));

            return true;
        }
Example #10
0
 public bool Get(Configuration.ConfFolder folder, Configuration.ConfEntry entry, bool defaultValue)
 {
     return Convert.ToBoolean(this.Get(folder, entry, defaultValue ? Boolean.TrueString : Boolean.FalseString));
 }
Example #11
0
 public ConfigurationEventArgs(Configuration.ConfFolder folder, Configuration.ConfEntry entry, object value)
 {
     this.folder = folder;
     this.entry = entry;
     this.value = value;
 }