Index: Ringtoets/Common/src/Ringtoets.Common.IO/Configurations/Helpers/XElementExtensions.cs =================================================================== diff -u -r8ebf5b222f3b052df95f6164ac488a5e7760cf68 -rdd18dca1346bd551789e19700faef78e48091771 --- Ringtoets/Common/src/Ringtoets.Common.IO/Configurations/Helpers/XElementExtensions.cs (.../XElementExtensions.cs) (revision 8ebf5b222f3b052df95f6164ac488a5e7760cf68) +++ Ringtoets/Common/src/Ringtoets.Common.IO/Configurations/Helpers/XElementExtensions.cs (.../XElementExtensions.cs) (revision dd18dca1346bd551789e19700faef78e48091771) @@ -125,6 +125,7 @@ { return null; } + return new TConverter().ConvertFromInvariantString(stringValue); } @@ -152,6 +153,7 @@ { return null; } + return new TConverter().ConvertFrom(doubleValue); } @@ -169,6 +171,7 @@ { throw new ArgumentNullException(nameof(parentElement)); } + if (stochastName == null) { throw new ArgumentNullException(nameof(stochastName)); @@ -194,6 +197,7 @@ { throw new ArgumentNullException(nameof(parentElement)); } + if (descendantElementName == null) { throw new ArgumentNullException(nameof(descendantElementName)); @@ -207,6 +211,8 @@ /// /// The element containing values for stochast parameters. /// The name of the stochast to find the parameter values for. + /// The configuration, or null when the + /// does not have stochast elements with the name . /// Thrown when any parameter is null. /// Thrown when the value for a parameter isn't in the correct format. /// Thrown when the value for a parameter represents a number less @@ -217,6 +223,7 @@ { throw new ArgumentNullException(nameof(calculationElement)); } + if (stochastName == null) { throw new ArgumentNullException(nameof(stochastName)); @@ -233,13 +240,16 @@ VariationCoefficient = element.GetDoubleValueFromDescendantElement(ConfigurationSchemaIdentifiers.VariationCoefficientElement) }; } + return null; } /// /// Gets a wave reduction configuration based on the values found in the . /// /// The element containing values for wave reduction parameters. + /// The configuration, or null when the does not + /// have wave reduction elements. /// Thrown when is null. /// Thrown when the value for break water type isn't valid. /// Thrown when the value for break water height, use foreshore profile or @@ -259,13 +269,16 @@ UseForeshoreProfile = calculationElement.GetBoolValueFromDescendantElement(ConfigurationSchemaIdentifiers.UseForeshore) }; } + return null; } /// /// Gets a scenario configuration based on the values found in the . /// /// The element containing values for scenario parameters. + /// The configuration, or null when the does not + /// have scenario elements. /// Thrown when is null. /// Thrown when the value for contribution or is relevant /// for scenario is not in the correct format to convert to a value. @@ -287,7 +300,26 @@ Contribution = calculationElement.GetDoubleValueFromDescendantElement(ConfigurationSchemaIdentifiers.ScenarioContribution) }; } + return null; } + + /// + /// Gets a hydraulic boundary location name based on the values found in the . + /// + /// The element containing values for scenario parameters. + /// Thrown when is null. + /// The hydraulic boundary location name, or null when the does not + /// have hydraulic boundary location elements. + public static string GetHydraulicBoundaryLocationName(this XElement calculationElement) + { + if (calculationElement == null) + { + throw new ArgumentNullException(nameof(calculationElement)); + } + + return calculationElement.GetStringValueFromDescendantElement(ConfigurationSchemaIdentifiers.HydraulicBoundaryLocationElementNew) + ?? calculationElement.GetStringValueFromDescendantElement(ConfigurationSchemaIdentifiers.HydraulicBoundaryLocationElementOld); + } } } \ No newline at end of file