[monkeydoc] Change namespace base from MonkeyDoc to Monodoc.
[mono.git] / mcs / tools / monkeydoc / MonkeyDoc / settings.cs
1 using System;
2 using System.Configuration;
3 using System.Collections.Specialized;
4
5 namespace Monodoc
6 {
7         public static class Settings
8         {
9                 static KeyValueConfigurationCollection libConfig;
10                 static KeyValueConfigurationCollection exeConfig;
11
12                 static Settings ()
13                 {
14                         try {
15                                 var config = ConfigurationManager.OpenExeConfiguration (System.Reflection.Assembly.GetExecutingAssembly ().Location);
16                                 libConfig = config.AppSettings.Settings;
17                         } catch {}
18
19                         try {
20                                 exeConfig = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None).AppSettings.Settings;
21                         } catch {}
22                 }
23
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];
31
32                         return element == null ? null : element.Value;
33                 }
34
35                 public static KeyValueConfigurationCollection AppSettings {
36                         get {
37                                 return exeConfig;
38                         }
39                 }
40
41                 public static KeyValueConfigurationCollection LibSettings {
42                         get {
43                                 return libConfig;
44                         }
45                 }
46         }
47 }