Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 9 additions & 10 deletions FileHelpers/MultiRecord/MultiRecordEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -174,17 +174,15 @@ public object[] ReadStream(IRecordReader reader)
{
mReader = freader
};

while (currentLine != null)
{
Type currentType = null;
try
{
mTotalRecords++;
currentRecord++;

line.ReLoad(currentLine);

Type currentType;
try
{
currentType = mRecordSelector(this, currentLine);
Expand Down Expand Up @@ -225,7 +223,7 @@ public object[] ReadStream(IRecordReader reader)
mLineNumber = freader.LineNumber,
mExceptionInfo = ex,
mRecordString = completeLine,
mRecordTypeName = RecordInfo.RecordType.Name
mRecordTypeName = currentType?.Name
};

mErrorManager.AddError(err);
Expand Down Expand Up @@ -577,25 +575,26 @@ private void ReadNextRecord()
{
mReader = mAsyncReader
};

while (true)
{
Type currentType = null;
if (currentLine != null)
{
try
{
mTotalRecords++;

Type currType = mRecordSelector(this, currentLine);
currentType = mRecordSelector(this, currentLine);

line.ReLoad(currentLine);

if (currType != null)
if (currentType != null)
{
mRecordInfoTable.TryGetValue(currType, out IRecordInfo info);
mRecordInfoTable.TryGetValue(currentType, out IRecordInfo info);
if (info == null)
{
throw new BadUsageException("A record is of type '" + currType.Name +
throw new BadUsageException("A record is of type '" + currentType.Name +
"' which this engine is not configured to handle. Try adding this type to the constructor.");
}

Expand All @@ -622,7 +621,7 @@ private void ReadNextRecord()
mLineNumber = mAsyncReader.LineNumber,
mExceptionInfo = ex,
mRecordString = currentLine,
mRecordTypeName = RecordInfo.RecordType.Name
mRecordTypeName = currentType?.Name
};

mErrorManager.AddError(err);
Expand Down