Skip to content
Snippets Groups Projects
Commit 2bef5457 authored by Niko Ehrenfeuchter's avatar Niko Ehrenfeuchter :keyboard:
Browse files

Make common configuration file optional.

Refers to #29
parent 8296ac2d
Branches
Tags
No related merge requests found
...@@ -281,12 +281,15 @@ namespace ATxCommon.Serializables ...@@ -281,12 +281,15 @@ namespace ATxCommon.Serializables
// behaviour of the .NET XmlSerializer on duplicates: only the first occurrence is // behaviour of the .NET XmlSerializer on duplicates: only the first occurrence is
// used, all other ones are silentley being discarded - this way we simply append the // used, all other ones are silentley being discarded - this way we simply append the
// contents of the common config file to the host-specific and deserialize then: // contents of the common config file to the host-specific and deserialize then:
var common = XElement.Load(commonFile);
Log.Debug("Loaded common configuration XML file: [{0}]", commonFile);
var combined = XElement.Load(specificFile); var combined = XElement.Load(specificFile);
Log.Debug("Loaded host specific configuration XML file: [{0}]", specificFile); Log.Debug("Loaded host specific configuration XML file: [{0}]", specificFile);
combined.Add(common.Nodes()); // the common configuration file is optional, so check if it exists at all:
Log.Trace("Combined XML structure:\n\n{0}\n\n", combined); if (File.Exists(commonFile)) {
var common = XElement.Load(commonFile);
Log.Debug("Loaded common configuration XML file: [{0}]", commonFile);
combined.Add(common.Nodes());
Log.Trace("Combined XML structure:\n\n{0}\n\n", combined);
}
using (var reader = XmlReader.Create(new StringReader(combined.ToString()))) { using (var reader = XmlReader.Create(new StringReader(combined.ToString()))) {
Log.Debug("Trying to parse combined XML."); Log.Debug("Trying to parse combined XML.");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment