-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConfig.cs
More file actions
58 lines (52 loc) · 1.78 KB
/
Config.cs
File metadata and controls
58 lines (52 loc) · 1.78 KB
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
49
50
51
52
53
54
55
56
57
58
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
namespace L2Script.Library
{
public class Config
{
public string LoginIP = "127.0.0.1";
public string LoginPort = "2106";
public string Username = "";
public string Password = "";
public string GameServer = "1";
public string Toon = "1";
public string BlowfishKey = "6B60CB5B82CE90B1CC2B6C556C6C6C6C";
public Config(string configFile)
{
Debug.Information("Loading configuration file '" + configFile + "'.");
try
{
XmlDocument doc = new XmlDocument();
doc.Load(configFile);
LoginIP = GetConfigValue(doc, "LoginIP");
LoginPort = GetConfigValue(doc, "LoginPort");
Username = GetConfigValue(doc, "Username");
Password = GetConfigValue(doc, "Password");
GameServer = GetConfigValue(doc, "GameServer");
Toon = GetConfigValue(doc, "Toon");
BlowfishKey = GetConfigValue(doc, "BlowfishKey");
}
catch (Exception ex)
{
Debug.Exception("Error loading configuration file.", ex);
}
Debug.Information("Successfully loaded configuration file.");
}
private string GetConfigValue(XmlDocument doc, string key)
{
try
{
XmlNodeList nl = doc.GetElementsByTagName(key);
XmlElement e = (XmlElement)nl[0];
return e.InnerText;
}
catch (Exception)
{
return "";
}
}
}
}