Skip to content

Commit

Permalink
added config util singltone to read configurations
Browse files Browse the repository at this point in the history
  • Loading branch information
naolArega committed Nov 16, 2021
1 parent f4c0ace commit 07d1b18
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions lib/Config.cs
@@ -0,0 +1,44 @@
using System;
using System.IO;
using System.Xml;

namespace nginx_php_manager.lib
{
public class Config
{
public enum ConfigStatus
{
SUCCESS,
FAILED,
NO_CONFIG
};
private static string configFileName = "config";
private static XmlDocument configDocumment;

private Config() { }

public static ConfigStatus read()
{
if (File.Exists(configFileName))
{
configDocumment = new XmlDocument();
try
{
configDocumment.Load(
string.Format("{0}\\{1}.xml", Directory.GetCurrentDirectory(), configFileName)
);
return ConfigStatus.SUCCESS;

}
catch
{
return ConfigStatus.FAILED;
}
}
else
{
return ConfigStatus.NO_CONFIG;
}
}
}
}

0 comments on commit 07d1b18

Please sign in to comment.