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; }
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; }