Config reorganization
General refactor
This commit is contained in:
@@ -15,17 +15,10 @@ namespace Step.Config
|
||||
{
|
||||
public static void ReadStartupConfig()
|
||||
{
|
||||
// Read validation file
|
||||
XmlSchemaSet readerSettings = new XmlSchemaSet();
|
||||
|
||||
try
|
||||
{
|
||||
// Add Schema
|
||||
readerSettings.Add(null, BASE_PATH + "\\" + STARTUP_CONFIG_SCHEMA_PATH);
|
||||
// Open file reader
|
||||
XDocument xmlConfigFile = XDocument.Load(BASE_PATH + "\\" + STARTUP_CONFIG_PATH);
|
||||
// Validate file
|
||||
xmlConfigFile.Validate(readerSettings, ValidationHandler);
|
||||
// Get server file handler
|
||||
XDocument xmlConfigFile = GetXmlHandlerWithValidator(SERVER_CONFIG_SCHEMA_PATH, SERVER_CONFIG_PATH);
|
||||
|
||||
// Read nc Config with LINQ
|
||||
NcConfig = xmlConfigFile
|
||||
@@ -40,7 +33,7 @@ namespace Step.Config
|
||||
}).FirstOrDefault();
|
||||
|
||||
// Read server config with LINQ and save into static config
|
||||
ServerConfig.ServerStartupConfig = xmlConfigFile
|
||||
ServerStartupConfig = xmlConfigFile
|
||||
.Descendants(SERVER_CONFIG_KEY)
|
||||
.Select(x => new ServerConfigModel()
|
||||
{ // Set server config model data
|
||||
@@ -49,6 +42,9 @@ namespace Step.Config
|
||||
EnableDirectoryBrowsing = Convert.ToBoolean(x.Element("enableDirectoryBrowsing").Value)
|
||||
}).FirstOrDefault();
|
||||
|
||||
// Get Areas file handler
|
||||
xmlConfigFile = GetXmlHandlerWithValidator(AREAS_CONFIG_SCHEMA_PATH, AREAS_CONFIG_PATH);
|
||||
|
||||
// Read areas config with LINQ
|
||||
xmlConfigFile
|
||||
.Descendants(AREAS_CONFIG_KEY) // Get areas config node
|
||||
@@ -63,6 +59,20 @@ namespace Step.Config
|
||||
}
|
||||
}
|
||||
|
||||
private static XDocument GetXmlHandlerWithValidator(string configSchemaFilePath, string configFilePath)
|
||||
{
|
||||
// Create new instance
|
||||
XmlSchemaSet readerSettings = new XmlSchemaSet();
|
||||
// Add Schema
|
||||
readerSettings.Add(null, BASE_PATH + "\\" + configSchemaFilePath );
|
||||
|
||||
// Open file reader
|
||||
XDocument xmlConfigFile = XDocument.Load(BASE_PATH + "\\" + configFilePath);
|
||||
// Validate file
|
||||
xmlConfigFile.Validate(readerSettings, ValidationHandler);
|
||||
|
||||
return xmlConfigFile;
|
||||
}
|
||||
|
||||
private static void SetAreaValueByName(XElement element)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user