public static string GetValue(string sectionName, string key, string defaultValue) { SettingSectionItem item = (from s in _settings.Sections from i in s.Items where s.Name == sectionName && i.Key == key select i).SingleOrDefault(); if (item == null) { SettingSections section = (from s in _settings.Sections where s.Name == sectionName select s).SingleOrDefault(); if (section == null) { _settings.Sections.Add(section = new SettingSections() { Name = sectionName, Items = new List <SettingSectionItem>() }); } section.Items.Add(item = new SettingSectionItem() { Key = key, Value = defaultValue }); Save(); } return(item.Value); }
private static void SetValue(string sectionName, string key, string value) { SettingSectionItem item = (from s in _settings.Sections from i in s.Items where s.Name == sectionName && i.Key == key select i).SingleOrDefault(); if (item != null) { item.Value = value == null ? string.Empty : value; if (!SuppressSaving) { Save(); } } }