Lots of updates
This commit is contained in:
46
PWAPPv2/Source/Database/DatabaseConfig.cs
Normal file
46
PWAPPv2/Source/Database/DatabaseConfig.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml;
|
||||
|
||||
namespace PWAPPv2.Source.Database
|
||||
{
|
||||
class DatabaseConfig
|
||||
{
|
||||
public string host;
|
||||
public string user;
|
||||
public string password;
|
||||
public string database;
|
||||
|
||||
|
||||
public DatabaseConfig(string path)
|
||||
{
|
||||
XmlDocument cfg = new XmlDocument();
|
||||
try
|
||||
{
|
||||
cfg.Load(path);
|
||||
}
|
||||
catch(XmlException)
|
||||
{
|
||||
Console.WriteLine("An error has occured parsing the config file.");
|
||||
return;
|
||||
}
|
||||
catch(System.IO.FileNotFoundException)
|
||||
{
|
||||
Console.WriteLine("Config file could not be found!");
|
||||
}
|
||||
|
||||
XmlNodeList XHost = cfg.GetElementsByTagName("ODhost");
|
||||
XmlNodeList XUser = cfg.GetElementsByTagName("ODuser");
|
||||
XmlNodeList XPassword = cfg.GetElementsByTagName("ODpassword");
|
||||
XmlNodeList XDatabase = cfg.GetElementsByTagName("ODdatabase");
|
||||
|
||||
host = XHost[0].InnerText;
|
||||
user = XUser[0].InnerText;
|
||||
password = XPassword[0].InnerText;
|
||||
database = XDatabase[0].InnerText;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user