Index: DamEngine/trunk/src/Deltares.DamEngine.Data/General/Dike.cs =================================================================== diff -u -r5426 -r5430 --- DamEngine/trunk/src/Deltares.DamEngine.Data/General/Dike.cs (.../Dike.cs) (revision 5426) +++ DamEngine/trunk/src/Deltares.DamEngine.Data/General/Dike.cs (.../Dike.cs) (revision 5430) @@ -212,23 +212,7 @@ foreach (Location location in Locations) { - if (isPiping) - { - if (location.Segment == null) - { - throw new DikeException("Location " + location.Name + " has no segment defined"); - } - - if (location.Segment.SoilProfileProbabilities.Count < 1) - { - throw new DikeException("Location " + location.Name + " has no soil profiles defined"); - } - - if (location.Segment.SoilProfileProbabilities[0].SoilProfile2D != null) - { - throw new DikeException("A piping calculation with a 2D-geometry is not supported."); - } - } + ValidateLocationForPiping(isPiping, location); if (location.SurfaceLine != null) { @@ -246,27 +230,54 @@ throw new DikeException("Location " + location.Name + " has no scenarios, at least one scenario is required."); } - if (isOperational) - { - if (location.Scenarios.Count > 1) - { - throw new DikeException($"For Operational (DamLive), location {location.Name} has {location.Scenarios.Count} scenarios but only one is allowed!"); - } + ValidateLocationForOperational(isOperational, location); + } + } - if (location.SensorLocation != null) - { - foreach (Sensor sensorArray in location.SensorLocation.SensorGroup.SensorArray) - { - if (sensorArray.RelativeLocation < 0) - { - throw new DikeException($"For Operational (DamLive), location {location.Name} has sensor which are not relative to the starting point."); - } - } - } + private static void ValidateLocationForOperational(bool isOperational, Location location) + { + if (!isOperational) + { + return; + } + + if (location.Scenarios.Count > 1) + { + throw new DikeException($"For Operational (DamLive), location {location.Name} has {location.Scenarios.Count} scenarios but only one is allowed!"); + } + + if (location.SensorLocation != null) + { + if (location.SensorLocation.SensorGroup.SensorArray.Any(sensorArray => sensorArray.RelativeLocation < 0)) + { + throw new DikeException($"For Operational (DamLive), location {location.Name} has sensor which are not relative to the starting point."); } } } + private static void ValidateLocationForPiping(bool isPiping, Location location) + { + if (!isPiping) + { + return; + } + + if (location.Segment == null) + { + throw new DikeException("Location " + location.Name + " has no segment defined"); + } + + if (location.Segment.SoilProfileProbabilities.Count < 1) + { + throw new DikeException("Location " + location.Name + " has no soil profiles defined"); + } + + if (location.Segment.SoilProfileProbabilities[0].SoilProfile2D != null) + { + throw new DikeException("A piping calculation with a 2D-geometry is not supported."); + } + } + /// /// Adapt data so it is consistent ///