Index: Ringtoets/Common/src/Ringtoets.Common.Data/IllustrationPoints/GeneralResult.cs =================================================================== diff -u -rd7f56db6a475e07dd904bd61c0a56346aac4e565 -r92f0a266f3ee297a3e0332e9a36fc3ec70d47b59 --- Ringtoets/Common/src/Ringtoets.Common.Data/IllustrationPoints/GeneralResult.cs (.../GeneralResult.cs) (revision d7f56db6a475e07dd904bd61c0a56346aac4e565) +++ Ringtoets/Common/src/Ringtoets.Common.Data/IllustrationPoints/GeneralResult.cs (.../GeneralResult.cs) (revision 92f0a266f3ee297a3e0332e9a36fc3ec70d47b59) @@ -68,7 +68,7 @@ throw new ArgumentNullException(nameof(topLevelIllustrationPoints)); } - ValidateStochasts(stochasts); + StochastValidator.ValidateStochasts(stochasts); ValidateTopLevelIllustrationPoints(topLevelIllustrationPoints); ValidateStochastInChildren(topLevelIllustrationPoints, stochasts); @@ -103,7 +103,7 @@ return clone; } - private void ValidateStochastInChildren(IEnumerable topLevelillustrationPoints, IEnumerable stochasts) + private static void ValidateStochastInChildren(IEnumerable topLevelillustrationPoints, IEnumerable stochasts) { var childStochastNames = new List(); @@ -112,16 +112,17 @@ var topLevelFaultTreeIllustrationPoint = topLevelIllustrationPoint as TopLevelFaultTreeIllustrationPoint; if (topLevelFaultTreeIllustrationPoint != null) { - childStochastNames.AddRange(GetStochastNamesFromChildren(topLevelFaultTreeIllustrationPoint.FaultTreeNodeRoot)); + childStochastNames.AddRange(topLevelFaultTreeIllustrationPoint.FaultTreeNodeRoot.GetStochastNamesFromChildren()); continue; } var topLevelSubMechanismIllustrationPoint = topLevelIllustrationPoint as TopLevelSubMechanismIllustrationPoint; if (topLevelSubMechanismIllustrationPoint != null) { - childStochastNames.AddRange(topLevelSubMechanismIllustrationPoint.SubMechanismIllustrationPoint.Stochasts.Select(s => s.Name)); + childStochastNames.AddRange(topLevelSubMechanismIllustrationPoint.SubMechanismIllustrationPoint.GetStochastNames()); } } + childStochastNames = childStochastNames.Distinct().ToList(); IEnumerable topLevelStochastNames = stochasts.Select(s => s.Name); @@ -131,27 +132,6 @@ } } - private IEnumerable GetStochastNamesFromChildren(IllustrationPointNode nodeRoot) - { - var stochastNames = new List(); - var faultTreeData = nodeRoot.Data as FaultTreeIllustrationPoint; - if (faultTreeData != null) - { - stochastNames.AddRange(faultTreeData.Stochasts.Select(s => s.Name)); - foreach (IllustrationPointNode illustrationPointNode in nodeRoot.Children) - { - stochastNames.AddRange(GetStochastNamesFromChildren(illustrationPointNode)); - } - return stochastNames; - } - var subMechanismData = nodeRoot.Data as SubMechanismIllustrationPoint; - if (subMechanismData != null) - { - stochastNames.AddRange(subMechanismData.Stochasts.Select(s => s.Name)); - } - return stochastNames; - } - private static void ValidateTopLevelIllustrationPoints(IEnumerable topLevelIllustrationPoints) { bool hasDuplicateIllustrationPointsPerWindDirection = @@ -161,14 +141,5 @@ throw new ArgumentException(string.Format(Resources.GeneralResult_Imported_non_unique_closing_situations_or_wind_direction)); } } - - private static void ValidateStochasts(IEnumerable stochasts) - { - bool hasDuplicateStochasts = stochasts.HasDuplicates(s => s.Name); - if (hasDuplicateStochasts) - { - throw new ArgumentException(string.Format(Resources.GeneralResult_Imported_non_unique_stochasts)); - } - } } } \ No newline at end of file