1 |
william |
12 |
#define CONFIGURATION_TESTING // when defined will use config-dbg.ini, otherwise config.ini |
2 |
|
|
using System; |
3 |
|
|
using System.Collections.Generic; |
4 |
|
|
using System.Linq; |
5 |
|
|
using System.Text; |
6 |
|
|
using System.Windows.Forms; |
7 |
|
|
|
8 |
|
|
namespace EmuXPortal.Api |
9 |
|
|
{ |
10 |
|
|
public interface IConfigLoader |
11 |
|
|
{ |
12 |
|
|
bool LoadConfig(); |
13 |
|
|
bool LoadConfig(string path); |
14 |
|
|
} |
15 |
|
|
public interface IConfig |
16 |
|
|
{ |
17 |
|
|
string RomPath { get; } |
18 |
|
|
string DisplayDevice { get; } |
19 |
|
|
} |
20 |
|
|
public static class Config |
21 |
|
|
{ |
22 |
|
|
private static ConfigLoader loader = new ConfigLoader(); |
23 |
|
|
#region public class ConfigLoader : IConfigLoader |
24 |
|
|
private class ConfigLoader : IConfigLoader, IConfig |
25 |
|
|
{ |
26 |
|
|
private static string APP_PATH = Application.StartupPath; |
27 |
|
|
#if CONFIGURATION_TESTING |
28 |
|
|
private static string CONFIG_FILE = "config-dbg.ini"; |
29 |
|
|
#else |
30 |
|
|
private static string CONFIG_FILE = "config.ini"; |
31 |
|
|
#endif |
32 |
|
|
private static string CONFIG_FILE_PATH = string.Format(@"{0}\{1}", APP_PATH, CONFIG_FILE); |
33 |
|
|
#region IConfigLoader Members |
34 |
|
|
public bool LoadConfig() { return LoadConfig(CONFIG_FILE_PATH); } |
35 |
|
|
public bool LoadConfig(string path) |
36 |
|
|
{ |
37 |
|
|
bool loaded = false; |
38 |
|
|
return loaded; |
39 |
|
|
} |
40 |
|
|
#endregion |
41 |
|
|
#region IConfig Members |
42 |
|
|
public string RomPath { get; private set; } |
43 |
|
|
public string DisplayDevice { get; private set; } |
44 |
|
|
#endregion |
45 |
|
|
} |
46 |
|
|
#endregion |
47 |
|
|
|
48 |
|
|
#region IConfigLoader Members |
49 |
|
|
public static bool LoadConfig() { return loader.LoadConfig(); } |
50 |
|
|
public static bool LoadConfig(string path) { return loader.LoadConfig(path); } |
51 |
|
|
#endregion |
52 |
|
|
|
53 |
|
|
#region IConfig Members |
54 |
|
|
public static string RomPath { get { return loader.RomPath; } } |
55 |
|
|
public static string DisplayDevice { get { return loader.DisplayDevice; } } |
56 |
|
|
#endregion |
57 |
|
|
} |
58 |
|
|
|
59 |
|
|
|
60 |
|
|
} |