Index: Ringtoets/Common/src/Ringtoets.Common.IO/Readers/CalculationConfigurationReaderHelper.cs
===================================================================
diff -u -r90d46f7d803d51c0a68ee35569cf3c918e5387fd -r9b6fa40a91299ecbbaffdbc79faf904b6c492d2f
--- Ringtoets/Common/src/Ringtoets.Common.IO/Readers/CalculationConfigurationReaderHelper.cs (.../CalculationConfigurationReaderHelper.cs) (revision 90d46f7d803d51c0a68ee35569cf3c918e5387fd)
+++ Ringtoets/Common/src/Ringtoets.Common.IO/Readers/CalculationConfigurationReaderHelper.cs (.../CalculationConfigurationReaderHelper.cs) (revision 9b6fa40a91299ecbbaffdbc79faf904b6c492d2f)
@@ -41,19 +41,13 @@
/// The value of the element, or null when the
/// does not have descendant elements of .
/// Thrown when any parameter is null.
+ /// Thrown when the value isn't in the correct format.
+ /// Thrown when the value represents a number
+ /// less than or greater than .
public static double? GetDoubleValueFromDescendantElement(this XElement parentElement, string descendantElementName)
{
- if (parentElement == null)
- {
- throw new ArgumentNullException(nameof(parentElement));
- }
- if (descendantElementName == null)
- {
- throw new ArgumentNullException(nameof(descendantElementName));
- }
+ XElement descendantElement = parentElement.GetDescendantElement(descendantElementName);
- XElement descendantElement = GetDescendantElement(parentElement, descendantElementName);
-
return descendantElement != null
? (double?) XmlConvert.ToDouble(descendantElement.Value)
: null;
@@ -67,19 +61,10 @@
/// The value of the element, or null when the
/// does not have descendant elements of .
/// Thrown when any parameter is null.
- public static string GetStringValueFromDescendantElement(XElement parentElement, string descendantElementName)
+ public static string GetStringValueFromDescendantElement(this XElement parentElement, string descendantElementName)
{
- if (parentElement == null)
- {
- throw new ArgumentNullException(nameof(parentElement));
- }
- if (descendantElementName == null)
- {
- throw new ArgumentNullException(nameof(descendantElementName));
- }
+ XElement descendantElement = parentElement.GetDescendantElement(descendantElementName);
- XElement descendantElement = GetDescendantElement(parentElement, descendantElementName);
-
return descendantElement?.Value;
}
@@ -91,9 +76,10 @@
/// The value, or null when the
/// does not have descendant elements of .
/// Thrown when any parameter is null.
- public static bool? GetBoolValueFromDescendantElement(XElement parentElement, string descendantElementName)
+ /// Thrown when the value does not represent a value.
+ public static bool? GetBoolValueFromDescendantElement(this XElement parentElement, string descendantElementName)
{
- XElement descendantElement = GetDescendantElement(parentElement, descendantElementName);
+ XElement descendantElement = parentElement.GetDescendantElement(descendantElementName);
return descendantElement != null
? (bool?) XmlConvert.ToBoolean(descendantElement.Value)
@@ -109,9 +95,10 @@
/// The converted value, or null when the
/// does not have descendant elements of .
/// Thrown when any parameter is null.
- public static object GetConvertedValueFromDescendantElement(XElement parentElement, string descendantElementName) where TConverter : TypeConverter, new()
+ /// Thrown when the conversion cannot be performed.
+ public static object GetConvertedValueFromDescendantElement(this XElement parentElement, string descendantElementName) where TConverter : TypeConverter, new()
{
- string stringValue = GetStringValueFromDescendantElement(parentElement, descendantElementName);
+ string stringValue = parentElement.GetStringValueFromDescendantElement(descendantElementName);
if (stringValue == null)
{
return null;
@@ -127,7 +114,7 @@
/// The stochast element, or null when the
/// does not have stochast elements with the name .
/// Thrown when any parameter is null.
- public static XElement GetStochastElement(XElement parentElement, string stochastName)
+ public static XElement GetStochastElement(this XElement parentElement, string stochastName)
{
if (parentElement == null)
{
@@ -152,7 +139,7 @@
/// The element, or null when the
/// does not have descendant elements of .
/// Thrown when any parameter is null.
- public static XElement GetDescendantElement(XElement parentElement, string descendantElementName)
+ public static XElement GetDescendantElement(this XElement parentElement, string descendantElementName)
{
if (parentElement == null)
{