/// <summary> /// Given a string dictionary, parse the .config file for entries matching a prefix and midfix (located after the prefix), and add to the dictionary /// </summary> /// <param name="Coll">Your dictionary</param> /// <param name="Prefix">Your prefix</param> /// <param name="Midfix">Your "midfix"</param> public static void BuildCollectionFromConfig(StringDictionary Coll, string Prefix, string Midfix) { if (Coll == null) { Coll = new StringDictionary(); } if (Midfix == null) { Midfix = string.Empty; } if (string.IsNullOrEmpty(Prefix)) { throw new ApplicationException("SetupCollectionFromConfig requires a prefix and optional midfix to lookup values."); } string[] Keys = ServerDependentSection.AllKeys; foreach (string Key in Keys) { if (Key.StartsWith(Prefix + Midfix) && !Coll.ContainsKey(Key)) { Coll.Add(Key.Remove(0, Prefix.Length), ServerDependentSection[Key]); } } }