Index: Ringtoets/Common/src/Ringtoets.Common.IO/Readers/ConfigurationReader.cs
===================================================================
diff -u -r77ae070cdceab659705f8e3e9d4a9788d7af7334 -re1714dc7e1c63c28c493be6dcb06b38bf1e1cb0e
--- Ringtoets/Common/src/Ringtoets.Common.IO/Readers/ConfigurationReader.cs (.../ConfigurationReader.cs) (revision 77ae070cdceab659705f8e3e9d4a9788d7af7334)
+++ Ringtoets/Common/src/Ringtoets.Common.IO/Readers/ConfigurationReader.cs (.../ConfigurationReader.cs) (revision e1714dc7e1c63c28c493be6dcb06b38bf1e1cb0e)
@@ -21,6 +21,8 @@
using System;
using System.IO;
+using System.Xml;
+using System.Xml.Linq;
using Core.Common.IO.Exceptions;
using Core.Common.Utils;
using Core.Common.Utils.Builders;
@@ -34,6 +36,8 @@
/// The type of calculation items read from XML.
public abstract class ConfigurationReader
{
+ protected readonly XDocument xmlDocument;
+
///
/// Creates a new instance of .
///
@@ -51,6 +55,8 @@
IOUtils.ValidateFilePath(xmlFilePath);
ValidateFileExists(xmlFilePath);
+
+ xmlDocument = LoadDocument(xmlFilePath);
}
///
@@ -68,5 +74,28 @@
throw new CriticalFileReadException(message);
}
}
+
+ ///
+ /// Loads an XML document from the provided .
+ ///
+ /// The file path to load the XML document from.
+ /// Thrown when the XML document cannot be loaded.
+ private static XDocument LoadDocument(string xmlFilePath)
+ {
+ try
+ {
+ return XDocument.Load(xmlFilePath, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo | LoadOptions.SetBaseUri);
+ }
+ catch (Exception exception)
+ when (exception is InvalidOperationException
+ || exception is XmlException
+ || exception is IOException)
+ {
+ string message = new FileReaderErrorMessageBuilder(xmlFilePath)
+ .Build(CoreCommonUtilsResources.Error_General_IO_Import_ErrorMessage);
+
+ throw new CriticalFileReadException(message, exception);
+ }
+ }
}
}
\ No newline at end of file
Index: Ringtoets/Common/src/Ringtoets.Common.IO/Ringtoets.Common.IO.csproj
===================================================================
diff -u -r77ae070cdceab659705f8e3e9d4a9788d7af7334 -re1714dc7e1c63c28c493be6dcb06b38bf1e1cb0e
--- Ringtoets/Common/src/Ringtoets.Common.IO/Ringtoets.Common.IO.csproj (.../Ringtoets.Common.IO.csproj) (revision 77ae070cdceab659705f8e3e9d4a9788d7af7334)
+++ Ringtoets/Common/src/Ringtoets.Common.IO/Ringtoets.Common.IO.csproj (.../Ringtoets.Common.IO.csproj) (revision e1714dc7e1c63c28c493be6dcb06b38bf1e1cb0e)
@@ -46,6 +46,7 @@
True
+
Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/Readers/PipingConfigurationReader.cs
===================================================================
diff -u -r77ae070cdceab659705f8e3e9d4a9788d7af7334 -re1714dc7e1c63c28c493be6dcb06b38bf1e1cb0e
--- Ringtoets/Piping/src/Ringtoets.Piping.IO/Readers/PipingConfigurationReader.cs (.../PipingConfigurationReader.cs) (revision 77ae070cdceab659705f8e3e9d4a9788d7af7334)
+++ Ringtoets/Piping/src/Ringtoets.Piping.IO/Readers/PipingConfigurationReader.cs (.../PipingConfigurationReader.cs) (revision e1714dc7e1c63c28c493be6dcb06b38bf1e1cb0e)
@@ -41,8 +41,6 @@
///
internal class PipingConfigurationReader : ConfigurationReader
{
- private readonly XDocument xmlDocument;
-
///
/// Creates a new instance of .
///
@@ -57,8 +55,6 @@
///
internal PipingConfigurationReader(string xmlFilePath) : base(xmlFilePath)
{
- xmlDocument = LoadDocument(xmlFilePath);
-
ValidateToSchema(xmlDocument, xmlFilePath);
ValidateNotEmpty(xmlDocument, xmlFilePath);
@@ -74,29 +70,6 @@
}
///
- /// Loads an XML document from the provided .
- ///
- /// The file path to load the XML document from.
- /// Thrown when the XML document cannot be loaded.
- private static XDocument LoadDocument(string xmlFilePath)
- {
- try
- {
- return XDocument.Load(xmlFilePath, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo | LoadOptions.SetBaseUri);
- }
- catch (Exception exception)
- when (exception is InvalidOperationException
- || exception is XmlException
- || exception is IOException)
- {
- string message = new FileReaderErrorMessageBuilder(xmlFilePath)
- .Build(CoreCommonUtilsResources.Error_General_IO_Import_ErrorMessage);
-
- throw new CriticalFileReadException(message, exception);
- }
- }
-
- ///
/// Validates the provided XML document based on a predefined XML Schema Definition (XSD).
///
/// The XML document to validate.