Пример #1
0
 // Get a setting from a config file.
 public static string GetSetting(string section, string setting, configType cfgtype = configType.user)
 {
     try
     {
         IniFile config = new IniFile();
         if (cfgtype == configType.user)
         {
             config.Load(SETTINGS_FILE);
         }
         else if (cfgtype == configType.application)
         {
             config.Load(APPCONFIG_FILE);
         }
         IniSection main = config.Sections[section];
         string     value;
         main.Keys[setting].TryParseValue(out value);
         return(value);
     }
     // Catch NullReferences for VerifyUserSettings() to handle
     catch (NullReferenceException) { throw new NullReferenceException(); }
     catch (Exception e)
     {
         MessageBox.Show("Could not read setting from config file. " + setting + " " + e.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         io.LogToFile(e.ToString());
     }
     return(null);
 }
Пример #2
0
        public static Dictionary <string, string> valuePairs(configType section)
        {
            Dictionary <string, string> temp = new Dictionary <string, string>();

            foreach (var keyvalue in Instance.config[section.ToString()])
            {
                temp.Add(keyvalue.KeyName, keyvalue.Value);
            }
            return(temp);
        }
Пример #3
0
        string host, username, password, domain; //...

        #endregion Fields

        #region Constructors

        public config(string path, configType type)
        {
        }