public void Set(string section, string key, string value) { if (string.IsNullOrWhiteSpace(key)) { Common.Log.Debug("Settings: keys must be non-empty"); return; } if (string.IsNullOrWhiteSpace(section)) { _user.Global[key] = value; Common.Log.Debug($"Settings: Set Global[{key}]={value}"); } else if (_user.HasSection(section)) { _user[section][key] = value; Common.Log.Debug($"Settings: Set {section}[{key}]={value}"); } else { _user.Sections.AddSection(section); Common.Log.Debug($"Settings: Adding section {section}"); _user[section][key] = value; Common.Log.Debug($"Settings: Set {section}[{key}]={value}"); } try { Lock.EnterWriteLock(); FileParser.WriteFile(_userFile, _user); } catch (Exception e) { Common.Log.Error(e.Message); } finally { Lock.ExitWriteLock(); } }
private SettingValue GetSetting(IniData data, string section, string key) { Common.Log.Debug($"Settings: Get {section}[{key}]"); if (string.IsNullOrWhiteSpace(key)) { return(SettingValue.Empty); } if (string.IsNullOrWhiteSpace(section)) { return(new SettingValue(data.Global[key])); } else if (data.HasSection(section)) { return(new SettingValue(data[section][key])); } else { return(SettingValue.Empty); } }