Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the issue #62 in the branch DEV #64

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions src/FlatFile.Core/IFlatFileMultiEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ public interface IFlatFileMultiEngine : IFlatFileEngine
/// <param name="stream">The stream.</param>
void Read(Stream stream);
/// <summary>
/// Reads the specified stream reader.
/// </summary>
/// <param name="streamReader">The stream reader.</param>
void Read(StreamReader streamReader);
/// <summary>
/// Gets any records of type <typeparamref name="T"/> read by <see cref="Read"/>.
/// </summary>
/// <typeparam name="T"></typeparam>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,27 @@ protected override bool TryParseLine<TEntity>(string line, int lineNumber, ref T
public void Read(Stream stream)
{
var reader = new StreamReader(stream);
ReadInternal(reader);
}

/// <summary>
/// Reads the specified stream reader.
/// </summary>
/// <param name="streamReader">The stream reader.</param>
/// <exception cref="ParseLineException">Impossible to parse line</exception>
public void Read(StreamReader reader)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if this should be part of the contacts. We already have the ability to pass in a stream.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually would like the feature as well. I needed to use a custom StreamReader implementation for reading my files and ended up downcasting the engine to use that overload.

{
ReadInternal(reader);
}

/// <summary>
/// Internal method (private) to read from streamreader instead of stream
/// This way the client code have a way to specify encoding.
/// </summary>
/// <param name="reader">The stream reader to read.</param>
/// <exception cref="ParseLineException">Impossible to parse line</exception>
private void ReadInternal(StreamReader reader)
{
string line;
var lineNumber = 0;

Expand Down