Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/PipingSurfaceLinesCsvReader.cs =================================================================== diff -u -ra950714ad9510756331d862aa35695fa0b2ed03b -r5462a7ee52b9491f269d489a094d359f4f02f270 --- Ringtoets/Piping/src/Ringtoets.Piping.IO/PipingSurfaceLinesCsvReader.cs (.../PipingSurfaceLinesCsvReader.cs) (revision a950714ad9510756331d862aa35695fa0b2ed03b) +++ Ringtoets/Piping/src/Ringtoets.Piping.IO/PipingSurfaceLinesCsvReader.cs (.../PipingSurfaceLinesCsvReader.cs) (revision 5462a7ee52b9491f269d489a094d359f4f02f270) @@ -17,7 +17,7 @@ /// Expects data to be specified in the following format: /// {ID};X1;Y1;Z1...;(Xn;Yn;Zn) /// Where {ID} has to be a particular accepted text, and n triplets of doubles form the - /// 3D coordinates defining the geometric shape of the surfaceline.. + /// 3D coordinates defining the geometric shape of the surfaceline. /// public class PipingSurfaceLinesCsvReader : IDisposable { @@ -49,7 +49,7 @@ /// is invalid. public PipingSurfaceLinesCsvReader(string path) { - ValidateFilePath(path); + FileUtils.ValidateFilePath(path); filePath = path; } @@ -129,7 +129,7 @@ }; surfaceLine.SetGeometry(points); - CheckGeometry(surfaceLine); + CheckIfGeometryIsValid(surfaceLine); return surfaceLine; } @@ -142,16 +142,16 @@ return null; } - private void CheckGeometry(RingtoetsPipingSurfaceLine surfaceLine) + private void CheckIfGeometryIsValid(RingtoetsPipingSurfaceLine surfaceLine) { double[] lCoordinates = surfaceLine.ProjectGeometryToLZ().Select(p => p.X).ToArray(); for (int i = 1; i < lCoordinates.Length; i++) { if (lCoordinates[i - 1] > lCoordinates[i]) { - var expectedMessage = string.Format(Resources.PipingSurfaceLinesCsvReader_ReadLine_File_0_Line_1_Has_reclining_geometry, - filePath, 2); - throw new LineParseException(expectedMessage); + var message = string.Format(Resources.PipingSurfaceLinesCsvReader_ReadLine_File_0_Line_1_Has_reclining_geometry, + filePath, 2); + throw new LineParseException(message); } } } @@ -188,7 +188,7 @@ /// Gets the 3D surface line points. /// /// The tokenized string. - /// Set of all unique 3D world coordinate points. + /// Set of all 3D world coordinate points. /// A parse error has occurred for the current row, which may be caused by: /// /// contains a coordinate value that cannot be parsed as a double. @@ -219,7 +219,7 @@ Z = worldCoordinateValues[i * expectedValuesForPoint + 2] }; } - return points.Distinct(); + return points; } /// @@ -316,14 +316,14 @@ { if (!IsHeaderValid(header)) { - var expectedMessage = string.Format(Resources.PipingSurfaceLinesCsvReader_File_0_invalid_header, filePath); - throw new CriticalFileReadException(expectedMessage); + var message = string.Format(Resources.PipingSurfaceLinesCsvReader_File_0_invalid_header, filePath); + throw new CriticalFileReadException(message); } } else { - var expectedMessage = string.Format(Resources.Error_File_0_empty, filePath); - throw new CriticalFileReadException(expectedMessage); + var message = string.Format(Resources.Error_File_0_empty, filePath); + throw new CriticalFileReadException(message); } } @@ -332,7 +332,7 @@ /// /// The reader at the row from which counting should start. /// The current line, used for error messaging. - /// An integer greater than or equal to 0. + /// An integer greater than or equal to 0, being the number of surfaceline rows. /// An I/O exception occurred. private int CountNonEmptyLines(TextReader reader, int currentLine) { @@ -392,33 +392,5 @@ } return valid; } - - /// - /// Validates the file path. - /// - /// The file path to be validated. - /// is invalid. - private void ValidateFilePath(string path) - { - if (string.IsNullOrWhiteSpace(path)) - { - throw new ArgumentException(Resources.Error_PathMustBeSpecified); - } - - string name; - try - { - name = Path.GetFileName(path); - } - catch (ArgumentException e) - { - throw new ArgumentException(String.Format(Resources.Error_PathCannotContainCharacters_0_, - String.Join(", ", Path.GetInvalidFileNameChars())), e); - } - if (string.Empty == name) - { - throw new ArgumentException(Resources.Error_PathMustNotPointToFolder); - } - } } } \ No newline at end of file