public string Get(Configuration.ConfFolder folder, Configuration.ConfEntry entry, string defaultValue) { string result = defaultValue; try { lock (this.sections) { ConfigurationService.XmlSection section = this.sections.FirstOrDefault((ConfigurationService.XmlSection x) => string.Equals(x.Name, folder.ToString())); if (section != null) { ConfigurationService.XmlSectionEntry sectionEntry = section.Entries.FirstOrDefault((ConfigurationService.XmlSectionEntry x) => string.Equals(x.Key, entry.ToString())); if (sectionEntry != null) { result = sectionEntry.Value; } } } } catch (System.Exception e) { ConfigurationService.LOG.Error(e); } return(result); }
public bool Set(Configuration.ConfFolder folder, Configuration.ConfEntry entry, string value) { bool result; if (value == null) { result = false; } else { try { lock (this.sections) { ConfigurationService.XmlSection section = this.sections.FirstOrDefault((ConfigurationService.XmlSection x) => string.Equals(x.Name, folder.ToString())); if (section == null) { section = new ConfigurationService.XmlSection(folder.ToString()); this.sections.Add(section); } ConfigurationService.XmlSectionEntry sectionEntry = section.Entries.FirstOrDefault((ConfigurationService.XmlSectionEntry x) => string.Equals(x.Key, entry.ToString())); if (sectionEntry == null) { sectionEntry = new ConfigurationService.XmlSectionEntry(entry.ToString(), value); section.Entries.Add(sectionEntry); } else { sectionEntry.Value = value; } } } catch (System.Exception e) { ConfigurationService.LOG.Error("Failed to set value into registry", e); result = false; return(result); } EventHandlerTrigger.TriggerEvent <ConfigurationEventArgs>(this.onConfigurationEvent, this, new ConfigurationEventArgs(folder, entry, value)); this.DeferredSave(); result = true; } return(result); }