Index: Riskeer/Common/src/Riskeer.Common.IO/Configurations/Import/CalculationConfigurationReader.cs
===================================================================
diff -u -r943997f6ebeee5d581f7f1f828a236568f7323f2 -rbd73199a78ff34583e1ec88e34a66ecbc1774e74
--- Riskeer/Common/src/Riskeer.Common.IO/Configurations/Import/CalculationConfigurationReader.cs (.../CalculationConfigurationReader.cs) (revision 943997f6ebeee5d581f7f1f828a236568f7323f2)
+++ Riskeer/Common/src/Riskeer.Common.IO/Configurations/Import/CalculationConfigurationReader.cs (.../CalculationConfigurationReader.cs) (revision bd73199a78ff34583e1ec88e34a66ecbc1774e74)
@@ -65,6 +65,7 @@
/// - points to a file that does not contain valid XML.
/// - points to a file that does not pass the schema validation.
/// - points to a file that does not contain configuration elements.
+ /// - Thrown when something goes wrong while migrating.
///
///
protected CalculationConfigurationReader(string xmlFilePath, CalculationConfigurationSchemaDefinition[] schemaDefinitions)
@@ -111,7 +112,7 @@
/// Gets the correct schema definition depending on the version.
///
/// All the schema definitions.
- /// The schema definition that belongs to the XML file.
+ /// The schema definition that corresponds to the XML file.
/// Thrown when the version
/// from the XML file is not supported.
private CalculationConfigurationSchemaDefinition GetSchemaDefinition(IEnumerable schemaDefinitions)
@@ -124,8 +125,7 @@
combinedXmlSchemaDefinition.Validate(xmlDocument);
- string versionNumberString = xmlDocument.Element(ConfigurationSchemaIdentifiers.ConfigurationElement).Attribute(ConfigurationSchemaIdentifiers.VersionAttribute).Value;
- versionNumber = int.Parse(versionNumberString);
+ versionNumber = GetVersionNumber();
}
catch (XmlSchemaValidationException)
{
@@ -145,11 +145,18 @@
return schemaDefinition;
}
+ private int GetVersionNumber()
+ {
+ string versionNumberString = xmlDocument.Element(ConfigurationSchemaIdentifiers.ConfigurationElement).Attribute(ConfigurationSchemaIdentifiers.VersionAttribute).Value;
+ int versionNumber = int.Parse(versionNumberString);
+ return versionNumber;
+ }
+
///
- /// Migrates the XML document to newer versions when needed/
+ /// Migrates the XML document to newer versions when needed.
///
/// All the schema definitions.
- /// The schema definition for the version
+ /// The schema definition corresponding to the version
/// of the XML document.
/// Thrown when something goes wrong
/// while migrating.
@@ -202,8 +209,7 @@
///
/// Loads an XML document from the .
///
- /// Thrown when
- /// the XML document cannot be loaded.
+ /// Thrown when the XML document cannot be loaded.
private XDocument LoadDocument()
{
try
@@ -232,11 +238,22 @@
///
/// A string representing the main schema definition.
/// A containing
- /// zero to more nested schema definitions
+ /// zero to more nested schema definitions.
/// Thrown when the XML document does not match
/// the provided schema definitions.
/// Thrown when does not
/// reference the default schema definition ConfiguratieSchema.xsd.
+ /// Thrown when:
+ ///
+ /// - is invalid.
+ /// - contains invalid schema definition values.
+ /// - , all together with its referenced
+ /// , contains an invalid schema definition.
+ /// - contains schema definitions that are not
+ /// referenced by .
+ ///
+ ///
+
private void ValidateToSchema(string mainSchemaDefinition, IDictionary nestedSchemaDefinitions)
{
if (!mainSchemaDefinition.Contains(defaultSchemaName))
Index: Riskeer/Common/src/Riskeer.Common.IO/Configurations/Import/CalculationConfigurationSchemaDefinition.cs
===================================================================
diff -u -rced4d3286ef6a071e8b29ffc3998ca319d4a2120 -rbd73199a78ff34583e1ec88e34a66ecbc1774e74
--- Riskeer/Common/src/Riskeer.Common.IO/Configurations/Import/CalculationConfigurationSchemaDefinition.cs (.../CalculationConfigurationSchemaDefinition.cs) (revision ced4d3286ef6a071e8b29ffc3998ca319d4a2120)
+++ Riskeer/Common/src/Riskeer.Common.IO/Configurations/Import/CalculationConfigurationSchemaDefinition.cs (.../CalculationConfigurationSchemaDefinition.cs) (revision bd73199a78ff34583e1ec88e34a66ecbc1774e74)
@@ -19,26 +19,33 @@
// Stichting Deltares and remain full property of Stichting Deltares at all times.
// All rights reserved.
+using System;
using System.Collections.Generic;
namespace Riskeer.Common.IO.Configurations.Import
{
///
- /// Class that represents calculation configuration schema definition.
+ /// Class that represents a calculation configuration schema definition.
///
public class CalculationConfigurationSchemaDefinition
{
///
/// Creates a new instance of .
///
- /// The version number of the xml that is read.
- /// The main schema definition xsd.
+ /// The version number of the xml that applies to this definition.
+ /// The main schema definition.
/// The nested schema definitions.
/// The migration script.
+ /// Thrown when is null.
public CalculationConfigurationSchemaDefinition(int versionNumber, string mainSchemaDefinition,
IDictionary nestedSchemaDefinitions,
string migrationScript)
{
+ if (NestedSchemaDefinitions == null)
+ {
+ throw new ArgumentNullException(nameof(nestedSchemaDefinitions));
+ }
+
VersionNumber = versionNumber;
MainSchemaDefinition = mainSchemaDefinition;
NestedSchemaDefinitions = nestedSchemaDefinitions;