-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathConfig.cs
39 lines (31 loc) · 991 Bytes
/
Config.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
using System;
using System.Collections;
using System.IO;
namespace OpenSMO {
public class Config {
public string Filename;
public Hashtable Data;
public Config(string Filename) {
this.Filename = Filename;
Data = new Hashtable();
string[] lines = File.ReadAllLines(Filename);
foreach (string line in lines) {
if (line.Trim().StartsWith("//") || line.Trim() == "")
continue;
string[] parse = line.Trim().Split(new char[] { '=' }, 2);
if (parse.Length != 2)
continue;
Data[parse[0].Trim()] = parse[1].Trim();
}
}
public bool Contains(string Key) {
return Data.ContainsKey(Key);
}
public string Get(string Key) {
if (Contains(Key))
return (string)Data[Key];
else
return "";
}
}
}