public TaskmanParameter GetParameter(string name) { TaskmanParameter matchingParameter = _supportedParameters .SingleOrDefault(parameter => parameter.Name == name); if (matchingParameter == null) { throw new TaskManException(Messages.UnknownParameterName, name); } return(matchingParameter); }
public void SetParameter(string name, string value, bool setGlobally) { TaskmanParameter matchingParameter = GetParameter(name); if (matchingParameter.IsUserScoped && setGlobally) { throw new TaskManException($"Parameter '{name}' can only be set at the user level"); } Configuration configuration = setGlobally ? _globalConfiguration : _userConfiguration; configuration.AppSettings.Settings.Add(name, value); configuration.Save(ConfigurationSaveMode.Full); }
public string GetValue(string name, bool forceGetGlobal = false) { TaskmanParameter matchingParameter = GetParameter(name); string userValue = _userConfiguration.AppSettings.Settings[name]?.Value; string globalValue = _globalConfiguration.AppSettings.Settings[name]?.Value; if (userValue != null && !forceGetGlobal) { return(userValue); } else if (globalValue != null) { return(globalValue); } else if (matchingParameter.IsUserScoped && forceGetGlobal) { return(null); } else { return(matchingParameter.DefaultValue); } }