Index: Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/IO/HydraRingSettingsCsvReader.cs
===================================================================
diff -u -re43f4bf3f03c8566f64f02cac30dd9444f6dfa34 -rc7843d3b8c846c4aab66ba32e67f883b6555932b
--- Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/IO/HydraRingSettingsCsvReader.cs (.../HydraRingSettingsCsvReader.cs) (revision e43f4bf3f03c8566f64f02cac30dd9444f6dfa34)
+++ Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/IO/HydraRingSettingsCsvReader.cs (.../HydraRingSettingsCsvReader.cs) (revision c7843d3b8c846c4aab66ba32e67f883b6555932b)
@@ -1,6 +1,6 @@
// Copyright (C) Stichting Deltares 2016. All rights reserved.
//
-// This file is part of Ringtoets.
+// This fileContents is part of Ringtoets.
//
// Ringtoets is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
@@ -27,43 +27,43 @@
namespace Ringtoets.HydraRing.Calculation.IO
{
///
- /// An abstract reader base for HydraRing settings readers.
+ /// An abstract base for Hydra-Ring settings readers.
///
- /// The output format of the read settings.
- internal abstract class HydraRingSettingsCsvReader
+ /// The output format of the read settings.
+ internal abstract class HydraRingSettingsCsvReader
{
private const char separator = ';';
private readonly string fileContents;
- private readonly TOuput settings;
+ private readonly TOutput settings;
///
/// Creates a new instance of .
///
- /// The file to read.
- /// The provided settings object to import the read settings on.
- /// Thrown when or is null.
- protected HydraRingSettingsCsvReader(string file, TOuput settings)
+ /// The fileContents to read.
+ /// The provided settings object to add the read settings to.
+ /// Thrown when or is null.
+ protected HydraRingSettingsCsvReader(string fileContents, TOutput settings)
{
- if (string.IsNullOrEmpty(file))
+ if (string.IsNullOrEmpty(fileContents))
{
- throw new ArgumentNullException("file", @"A file must be set.");
+ throw new ArgumentNullException("fileContents", @"File contents must be set.");
}
if (settings == null)
{
- throw new ArgumentNullException("settings", @"The settinsg object must be provided.");
+ throw new ArgumentNullException("settings", @"The settings object must be provided.");
}
- fileContents = file;
+ this.fileContents = fileContents;
this.settings = settings;
}
///
- /// Reads the settings from the file.
+ /// Reads the settings from the fileContents.
///
/// A with the settings.
- public TOuput ReadSettings()
+ public TOutput ReadSettings()
{
var lines = fileContents.Split('\n');
@@ -75,7 +75,10 @@
return settings;
}
- protected TOuput Settings
+ ///
+ /// Gets the read settings.
+ ///
+ protected TOutput Settings
{
get
{
@@ -84,36 +87,48 @@
}
///
- /// Creates a setting from one line in the file.
+ // Creates a setting object from the provided line and adds it to .
///
/// The line to create the setting for.
protected abstract void CreateSetting(IList line);
+ ///
+ /// Gets a string value from the given .
+ ///
+ /// The element to extract the string value from.
+ /// The extracted string value.
protected static string GetStringValueFromElement(string element)
{
return element.Trim().Replace("\"", "");
}
+ ///
+ /// Gets an int value from the given .
+ ///
+ /// The element to extract the int value from.
+ /// The extracted int value.
protected static int GetIntValueFromElement(string element)
{
- return int.Parse(GetStringValueFromElement(element));
+ return int.Parse(GetStringValueFromElement(element), CultureInfo.InvariantCulture);
}
+ ///
+ /// Gets a double value from the given .
+ ///
+ /// The element to extract the double value from.
+ /// The extracted double value.
protected static double GetDoubleValueFromElement(string element)
{
return double.Parse(GetStringValueFromElement(element), CultureInfo.InvariantCulture);
}
private static string[] TokenizeString(string readText)
{
- if (!readText.Contains(separator))
- {
- return new string[]
- {};
- }
- return readText.Split(separator)
- .TakeWhile(text => !string.IsNullOrEmpty(text))
- .ToArray();
+ return !readText.Contains(separator)
+ ? new string[0]
+ : readText.Split(separator)
+ .TakeWhile(text => !string.IsNullOrEmpty(text))
+ .ToArray();
}
}
}
\ No newline at end of file