forked from nitschk/h24
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SettingsManager.cs
41 lines (36 loc) · 1021 Bytes
/
SettingsManager.cs
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace h24
{
public static class SettingsManager
{
private static Dictionary<string, string> _settingsCache;
static SettingsManager()
{
_settingsCache = new Dictionary<string, string>();
LoadSettings();
}
private static void LoadSettings()
{
using (var db = new klc01())
{
var settings = db.settings.ToList();
foreach (var setting in settings)
{
_settingsCache[setting.config_name] = setting.config_value;
}
}
}
public static string GetSetting(string key)
{
if (_settingsCache.ContainsKey(key))
{
return _settingsCache[key];
}
return ""; // Or throw an exception, depending on your needs
}
}
}