Example #1
0
        public TaskmanParameter GetParameter(string name)
        {
            TaskmanParameter matchingParameter = _supportedParameters
                                                 .SingleOrDefault(parameter => parameter.Name == name);

            if (matchingParameter == null)
            {
                throw new TaskManException(Messages.UnknownParameterName, name);
            }

            return(matchingParameter);
        }
Example #2
0
        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);
        }
Example #3
0
        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);
            }
        }