Index: Ringtoets/Common/src/Ringtoets.Common.Data/AssessmentSection/AssessmentSectionExtensions.cs
===================================================================
diff -u -rf7d73da8b5830eb8d37f50e94eb85e22f3e6b1c3 -raef20c08e43fb95b037791c98c8e088352061c5e
--- Ringtoets/Common/src/Ringtoets.Common.Data/AssessmentSection/AssessmentSectionExtensions.cs (.../AssessmentSectionExtensions.cs) (revision f7d73da8b5830eb8d37f50e94eb85e22f3e6b1c3)
+++ Ringtoets/Common/src/Ringtoets.Common.Data/AssessmentSection/AssessmentSectionExtensions.cs (.../AssessmentSectionExtensions.cs) (revision aef20c08e43fb95b037791c98c8e088352061c5e)
@@ -52,7 +52,8 @@
/// contains an invalid value of .
/// Thrown when
/// contains a valid value of , but unsupported.
- public static RoundedDouble GetNormativeAssessmentLevel(this IAssessmentSection assessmentSection, HydraulicBoundaryLocation hydraulicBoundaryLocation)
+ public static RoundedDouble GetNormativeAssessmentLevel(this IAssessmentSection assessmentSection,
+ HydraulicBoundaryLocation hydraulicBoundaryLocation)
{
if (assessmentSection == null)
{
@@ -82,6 +83,69 @@
throw new NotSupportedException();
}
+ return GetAssessmentLevelFromCalculations(hydraulicBoundaryLocation, calculations);
+ }
+
+ ///
+ /// Gets the assessment level for a based on .
+ ///
+ /// The assessment section to get the assessment level from.
+ /// The hydraulic boundary location to get the assessment level for.
+ /// The category type to use while obtaining the assessment level.
+ /// The assessment level or when:
+ ///
+ /// - is null;
+ /// - is not part of ;
+ /// - contains no corresponding calculation output.
+ ///
+ ///
+ /// Thrown when
+ /// is null.
+ /// Thrown when
+ /// is an invalid .
+ /// Thrown when
+ /// is a valid but unsupported .
+ public static RoundedDouble GetAssessmentLevel(this IAssessmentSection assessmentSection,
+ HydraulicBoundaryLocation hydraulicBoundaryLocation,
+ AssessmentSectionCategoryType categoryType)
+ {
+ if (assessmentSection == null)
+ {
+ throw new ArgumentNullException(nameof(assessmentSection));
+ }
+
+ if (!Enum.IsDefined(typeof(AssessmentSectionCategoryType), categoryType))
+ {
+ throw new InvalidEnumArgumentException(nameof(categoryType),
+ (int) categoryType,
+ typeof(AssessmentSectionCategoryType));
+ }
+
+ IEnumerable calculations;
+
+ switch (categoryType)
+ {
+ case AssessmentSectionCategoryType.FactorizedSignalingNorm:
+ calculations = assessmentSection.WaterLevelCalculationsForFactorizedSignalingNorm;
+ break;
+ case AssessmentSectionCategoryType.SignalingNorm:
+ calculations = assessmentSection.WaterLevelCalculationsForSignalingNorm;
+ break;
+ case AssessmentSectionCategoryType.LowerLimitNorm:
+ calculations = assessmentSection.WaterLevelCalculationsForLowerLimitNorm;
+ break;
+ case AssessmentSectionCategoryType.FactorizedLowerLimitNorm:
+ calculations = assessmentSection.WaterLevelCalculationsForFactorizedLowerLimitNorm;
+ break;
+ default:
+ throw new NotSupportedException();
+ }
+
+ return GetAssessmentLevelFromCalculations(hydraulicBoundaryLocation, calculations);
+ }
+
+ private static RoundedDouble GetAssessmentLevelFromCalculations(HydraulicBoundaryLocation hydraulicBoundaryLocation, IEnumerable calculations)
+ {
return calculations.FirstOrDefault(c => ReferenceEquals(c.HydraulicBoundaryLocation, hydraulicBoundaryLocation))?.Output?.Result
?? RoundedDouble.NaN;
}