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); }
/// <summary> /// Defines UI section in settings window. /// </summary> /// <typeparam name="TSectionControl">Type of UI control responsive for displaying settings.</typeparam> /// <typeparam name="TViewModel">Type of ViewModel for the UI control.</typeparam> public void DefineSettingsSection <TSectionControl, TViewModel>() where TSectionControl : SettingsSection where TViewModel : ViewModelBase { SettingSections.Add(new SettingSectionDefinition(typeof(TSectionControl), typeof(TViewModel))); }