Index: Ringtoets/Common/src/Ringtoets.Common.Data/AssessmentSection/AssessmentSectionExtensions.cs =================================================================== diff -u -raef20c08e43fb95b037791c98c8e088352061c5e -r56b15dc5a50c0a36b0a8949a35f8dd20437e6cda --- Ringtoets/Common/src/Ringtoets.Common.Data/AssessmentSection/AssessmentSectionExtensions.cs (.../AssessmentSectionExtensions.cs) (revision aef20c08e43fb95b037791c98c8e088352061c5e) +++ Ringtoets/Common/src/Ringtoets.Common.Data/AssessmentSection/AssessmentSectionExtensions.cs (.../AssessmentSectionExtensions.cs) (revision 56b15dc5a50c0a36b0a8949a35f8dd20437e6cda) @@ -24,6 +24,8 @@ using System.ComponentModel; using System.Linq; using Core.Common.Base.Data; +using Ringtoets.AssemblyTool.Data; +using Ringtoets.Common.Data.AssemblyTool; using Ringtoets.Common.Data.Contribution; using Ringtoets.Common.Data.Hydraulics; @@ -144,6 +146,56 @@ return GetAssessmentLevelFromCalculations(hydraulicBoundaryLocation, calculations); } + /// + /// Gets the norm based on . + /// + /// The assessment section to get the norm from. + /// The category type to use while obtaining the norm. + /// The norm corresponding to the provided category type. + /// Thrown when + /// is null. + /// Thrown when + /// is an invalid . + /// Thrown when + /// is a valid but unsupported . + public static double GetNorm(this IAssessmentSection assessmentSection, + 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 categories = AssemblyToolCategoriesFactory.CreateAssessmentSectionAssemblyCategories( + assessmentSection.FailureMechanismContribution.SignalingNorm, + assessmentSection.FailureMechanismContribution.LowerLimitNorm); + + switch (categoryType) + { + case AssessmentSectionCategoryType.FactorizedSignalingNorm: + return categories.First(c => c.Group == AssessmentSectionAssemblyCategoryGroup.A) + .LowerBoundary; + case AssessmentSectionCategoryType.SignalingNorm: + return categories.First(c => c.Group == AssessmentSectionAssemblyCategoryGroup.B) + .LowerBoundary; + case AssessmentSectionCategoryType.LowerLimitNorm: + return categories.First(c => c.Group == AssessmentSectionAssemblyCategoryGroup.C) + .LowerBoundary; + case AssessmentSectionCategoryType.FactorizedLowerLimitNorm: + return categories.First(c => c.Group == AssessmentSectionAssemblyCategoryGroup.D) + .LowerBoundary; + default: + throw new NotSupportedException(); + } + } + private static RoundedDouble GetAssessmentLevelFromCalculations(HydraulicBoundaryLocation hydraulicBoundaryLocation, IEnumerable calculations) { return calculations.FirstOrDefault(c => ReferenceEquals(c.HydraulicBoundaryLocation, hydraulicBoundaryLocation))?.Output?.Result