Index: Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Parsers/HydraRingDatabaseParseHelper.cs
===================================================================
diff -u -r9bc5d8bc179ba0be25c9746859da3726b8b6a33e -r377ab5754aaebdd884c70b39bc44f1669d01efa8
--- Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Parsers/HydraRingDatabaseParseHelper.cs (.../HydraRingDatabaseParseHelper.cs) (revision 9bc5d8bc179ba0be25c9746859da3726b8b6a33e)
+++ Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Parsers/HydraRingDatabaseParseHelper.cs (.../HydraRingDatabaseParseHelper.cs) (revision 377ab5754aaebdd884c70b39bc44f1669d01efa8)
@@ -20,6 +20,7 @@
// All rights reserved.
using System;
+using System.Collections.Generic;
using System.Data.SQLite;
using Ringtoets.HydraRing.Calculation.Exceptions;
using Ringtoets.HydraRing.Calculation.Properties;
@@ -40,40 +41,37 @@
/// The query to perform when reading the database.
/// The section id to get the output for.
/// The exception message when there is no result.
- /// The action to perform for parsing the results from the database.
+ /// A with the key of the column and the value.
/// Thrown when any input parameter is null.
/// Thrown when the reader encounters an error while
/// reading the database.
- public static void Parse(string workingDirectory,
- string query,
- int sectionId,
- string exceptionMessage,
- Action readResultAction)
+ public static Dictionary ReadSingleLine(string workingDirectory,
+ string query,
+ int sectionId,
+ string exceptionMessage)
{
- ValidateParameters(workingDirectory, query, exceptionMessage, readResultAction);
+ ValidateParameters(workingDirectory, query, exceptionMessage);
try
{
using (var reader = new HydraRingDatabaseReader(workingDirectory, query, sectionId))
{
- reader.Execute();
- readResultAction(reader);
+ return reader.ReadLine();
}
}
catch (SQLiteException e)
{
throw new HydraRingFileParserException(Resources.Parse_Cannot_read_result_in_output_file, e);
}
- catch (Exception e) when (e is HydraRingDatabaseReaderException || e is InvalidCastException)
+ catch (HydraRingDatabaseReaderException e)
{
throw new HydraRingFileParserException(exceptionMessage, e);
}
}
private static void ValidateParameters(string workingDirectory,
string query,
- string exceptionMessage,
- Action readResultAction)
+ string exceptionMessage)
{
if (workingDirectory == null)
{
@@ -87,10 +85,6 @@
{
throw new ArgumentNullException(nameof(exceptionMessage));
}
- if (readResultAction == null)
- {
- throw new ArgumentNullException(nameof(readResultAction));
- }
}
}
}
\ No newline at end of file