public String Get(Configuration.ConfFolder folder, Configuration.ConfEntry entry, String defaultValue) { String result = defaultValue; try { lock (this.sections) { XmlSection section = this.sections.FirstOrDefault((x) => String.Equals(x.Name, folder.ToString())); if (section != null) { XmlSectionEntry sectionEntry = section.Entries.FirstOrDefault((x) => String.Equals(x.Key, entry.ToString())); if (sectionEntry != null) { result = sectionEntry.Value; } } } } catch (Exception e) { LOG.Error(e); } return(result); }
public bool Set(Configuration.ConfFolder folder, Configuration.ConfEntry entry, String value) { if (value == null) { return(false); } try { lock (this.sections) { XmlSection section = this.sections.FirstOrDefault((x) => String.Equals(x.Name, folder.ToString())); if (section == null) { section = new XmlSection(folder.ToString()); this.sections.Add(section); } XmlSectionEntry sectionEntry = section.Entries.FirstOrDefault((x) => String.Equals(x.Key, entry.ToString())); if (sectionEntry == null) { sectionEntry = new XmlSectionEntry(entry.ToString(), value); section.Entries.Add(sectionEntry); } else { sectionEntry.Value = value; } } } 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)); this.DeferredSave(); return(true); }