Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added config util singltone to read configurations
- Loading branch information
naolArega
committed
Nov 16, 2021
1 parent
f4c0ace
commit 07d1b18
Showing
1 changed file
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} | ||
} | ||
} |