2 using System.Configuration;
3 using System.Collections.Specialized;
7 public static class Settings
9 static KeyValueConfigurationCollection libConfig;
10 static KeyValueConfigurationCollection exeConfig;
15 var config = ConfigurationManager.OpenExeConfiguration (System.Reflection.Assembly.GetExecutingAssembly ().Location);
16 libConfig = config.AppSettings.Settings;
20 exeConfig = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None).AppSettings.Settings;
24 public static string Get (string key) {
25 KeyValueConfigurationElement element = null;
26 // We check the configuration in order: app first and then library itself
27 if (exeConfig != null)
28 element = exeConfig[key];
29 if (element == null && libConfig != null)
30 element = libConfig[key];
32 return element == null ? null : element.Value;
35 public static KeyValueConfigurationCollection AppSettings {
41 public static KeyValueConfigurationCollection LibSettings {