public static void Set(KEY key, List <string> StringList) { int count = 1; bool found = false; // remove ALL old key/value pairs from the dictionary (since the list parameter passed in can be different size than what's currently in dictionary) do { string key_string = string.Format("{0}{1}", key.ToString(), count); found = ConfigDictionary.ContainsKey(key_string); if (found) { ConfigDictionary.Remove(key_string); } count++; } while(found); // add the new key/value pairs to the dictionary for (int index = 0; index < StringList.Count; index++) { string key_string = string.Format("{0}{1}", key.ToString(), index + 1); ConfigDictionary.Add(key_string, StringList[index]); } timer.Enabled = true; timer.Interval = 1000; }
public static bool Get(KEY key, ref bool value) { string key_string = key.ToString(); if (ConfigDictionary.ContainsKey(key_string)) { value = ConfigDictionary[key_string] == "True"; return(true); } return(false); }
public static bool Get(KEY key, ref int value) { string key_string = key.ToString(); if (ConfigDictionary.ContainsKey(key_string)) { value = 0; Int32.TryParse(ConfigDictionary[key_string], out value); return(true); } return(false); }
public static void Set(KEY key, string value) { string key_string = key.ToString(); if (ConfigDictionary.ContainsKey(key_string)) // if the key/value pair exists... { ConfigDictionary.Remove(key_string); // ...remove the old key/value pair } ConfigDictionary.Add(key_string, value); // add the key/value pair to the dictionary timer.Enabled = true; timer.Interval = 1000; }
public static bool Get(KEY key, ref List <string> value) { value = new List <string>(); int count = 1; bool found = false; do { string key_string = string.Format("{0}{1}", key.ToString(), count); found = ConfigDictionary.ContainsKey(key_string); if (found) { value.Add(ConfigDictionary[key_string]); } count++; } while(found); return(value.Count() > 0); }
public static string GetKey(KEY key) { return(ConfigurationManager.AppSettings[key.ToString()].Trim()); }