blob: 8dd01e6e1246a9011e20622f3db9ed1042156900 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
using System;
using System.Configuration;
using System.Collections.Specialized;
namespace Monodoc
{
public static class Config
{
static KeyValueConfigurationCollection libConfig;
static KeyValueConfigurationCollection exeConfig;
static Config ()
{
try {
var config = ConfigurationManager.OpenExeConfiguration (System.Reflection.Assembly.GetExecutingAssembly ().Location);
libConfig = config.AppSettings.Settings;
} catch {}
try {
exeConfig = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None).AppSettings.Settings;
} catch {}
}
public static string Get (string key)
{
KeyValueConfigurationElement element = null;
// We check the configuration in order: app first and then library itself
if (exeConfig != null)
element = exeConfig[key];
if (element == null && libConfig != null)
element = libConfig[key];
return element == null ? null : element.Value;
}
public static KeyValueConfigurationCollection AppSettings {
get {
return exeConfig;
}
}
public static KeyValueConfigurationCollection LibSettings {
get {
return libConfig;
}
}
}
}
|