Index: Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Data/GrassCoverErosionOutwardsFailureMechanismExtensions.cs
===================================================================
diff -u -r871a2151d7a49d6f50699b6dea82c3e20ba6e409 -rcff4b928800b2a49ccaaaa49e7c87755d79b0169
--- Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Data/GrassCoverErosionOutwardsFailureMechanismExtensions.cs (.../GrassCoverErosionOutwardsFailureMechanismExtensions.cs) (revision 871a2151d7a49d6f50699b6dea82c3e20ba6e409)
+++ Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Data/GrassCoverErosionOutwardsFailureMechanismExtensions.cs (.../GrassCoverErosionOutwardsFailureMechanismExtensions.cs) (revision cff4b928800b2a49ccaaaa49e7c87755d79b0169)
@@ -21,8 +21,11 @@
using System;
using System.Collections.Generic;
+using System.ComponentModel;
using System.Linq;
-using Core.Common.Util.Extensions;
+using Core.Common.Base.Data;
+using Ringtoets.Common.Data.AssessmentSection;
+using Ringtoets.Common.Data.Contribution;
using Ringtoets.Common.Data.Hydraulics;
namespace Ringtoets.GrassCoverErosionOutwards.Data
@@ -33,31 +36,64 @@
public static class GrassCoverErosionOutwardsFailureMechanismExtensions
{
///
- /// Sets
- /// based upon the .
+ /// Gets the normative assessment level for a .
///
- /// The to update.
- /// The hydraulic boundary locations to use.
- /// Thrown when any parameter is null.
- public static void SetGrassCoverErosionOutwardsHydraulicBoundaryLocations(this GrassCoverErosionOutwardsFailureMechanism failureMechanism,
- IEnumerable hydraulicBoundaryLocations)
+ /// The assessment section to get the normative assessment level from.
+ /// The failure mechanism to get the normative assessment level from.
+ /// The hydraulic boundary location to get the normative assessment level for.
+ /// The normative assessment level or when:
+ ///
+ /// - is null;
+ /// - is not part of ;
+ /// - is not part of ;
+ /// - contains no corresponding calculation output.
+ ///
+ ///
+ /// Thrown when
+ /// or is null.
+ /// Thrown when
+ /// contains an invalid value of .
+ /// Thrown when
+ /// contains a valid value of , but unsupported.
+ public static RoundedDouble GetNormativeAssessmentLevel(this GrassCoverErosionOutwardsFailureMechanism failureMechanism,
+ IAssessmentSection assessmentSection,
+ HydraulicBoundaryLocation hydraulicBoundaryLocation)
{
if (failureMechanism == null)
{
throw new ArgumentNullException(nameof(failureMechanism));
}
- if (hydraulicBoundaryLocations == null)
+
+ if (assessmentSection == null)
{
- throw new ArgumentNullException(nameof(hydraulicBoundaryLocations));
+ throw new ArgumentNullException(nameof(assessmentSection));
}
- failureMechanism.HydraulicBoundaryLocations.Clear();
- if (!hydraulicBoundaryLocations.Any())
+ NormType normType = assessmentSection.FailureMechanismContribution.NormativeNorm;
+
+ if (!Enum.IsDefined(typeof(NormType), normType))
{
- return;
+ throw new InvalidEnumArgumentException(nameof(normType),
+ (int)normType,
+ typeof(NormType));
}
- failureMechanism.HydraulicBoundaryLocations.AddRange(hydraulicBoundaryLocations);
+ IEnumerable calculations;
+
+ switch (normType)
+ {
+ case NormType.Signaling:
+ calculations = failureMechanism.WaterLevelCalculationsForMechanismSpecificSignalingNorm;
+ break;
+ case NormType.LowerLimit:
+ calculations = failureMechanism.WaterLevelCalculationsForMechanismSpecificLowerLimitNorm;
+ break;
+ default:
+ throw new NotSupportedException();
+ }
+
+ return calculations.FirstOrDefault(c => ReferenceEquals(c.HydraulicBoundaryLocation, hydraulicBoundaryLocation))?.Output?.Result
+ ?? RoundedDouble.NaN;
}
}
}
\ No newline at end of file