From fc49a8246081133ce9ca70ee7782410017c05d05 Mon Sep 17 00:00:00 2001 From: Andre Guilherme Date: Tue, 26 Dec 2017 11:33:19 -0200 Subject: [PATCH 1/2] Fix the issue #62 in the branch DEV --- src/FlatFile.Core/IFlatFileMultiEngine.cs | 5 ++++ .../FixedLengthFileMultiEngine.cs | 23 ++++++++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/FlatFile.Core/IFlatFileMultiEngine.cs b/src/FlatFile.Core/IFlatFileMultiEngine.cs index a47b36d..e61dd4d 100644 --- a/src/FlatFile.Core/IFlatFileMultiEngine.cs +++ b/src/FlatFile.Core/IFlatFileMultiEngine.cs @@ -14,6 +14,11 @@ public interface IFlatFileMultiEngine : IFlatFileEngine /// The stream. void Read(Stream stream); /// + /// Reads the specified stream reader. + /// + /// The stream reader. + void Read(StreamReader streamReader); + /// /// Gets any records of type read by . /// /// diff --git a/src/FlatFile.FixedLength/Implementation/FixedLengthFileMultiEngine.cs b/src/FlatFile.FixedLength/Implementation/FixedLengthFileMultiEngine.cs index 360e4f5..6ac56dc 100644 --- a/src/FlatFile.FixedLength/Implementation/FixedLengthFileMultiEngine.cs +++ b/src/FlatFile.FixedLength/Implementation/FixedLengthFileMultiEngine.cs @@ -104,7 +104,7 @@ internal FixedLengthFileMultiEngine( /// IEnumerable<T>. public IEnumerable GetRecords() where T : class, new() { - return !results.ContainsKey(typeof (T)) ? new List() : results[typeof(T)].Cast(); + return !results.ContainsKey(typeof(T)) ? new List() : results[typeof(T)].Cast(); } /// @@ -138,6 +138,27 @@ protected override bool TryParseLine(string line, int lineNumber, ref T public void Read(Stream stream) { var reader = new StreamReader(stream); + ReadInternal(reader); + } + + /// + /// Reads the specified stream reader. + /// + /// The stream reader. + /// Impossible to parse line + public void Read(StreamReader reader) + { + ReadInternal(reader); + } + + /// + /// Internal method (private) to read from streamreader instead of stream + /// This way the client code have a way to specify encoding. + /// + /// The stream reader to read. + /// Impossible to parse line + private void ReadInternal(StreamReader reader) + { string line; var lineNumber = 0; From 0dd09242e42b88f0be3713e81f1608801fe61916 Mon Sep 17 00:00:00 2001 From: Andre Guilherme Date: Tue, 26 Dec 2017 13:42:32 -0200 Subject: [PATCH 2/2] Undo whitespace change in line 107 --- .../Implementation/FixedLengthFileMultiEngine.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/FlatFile.FixedLength/Implementation/FixedLengthFileMultiEngine.cs b/src/FlatFile.FixedLength/Implementation/FixedLengthFileMultiEngine.cs index 6ac56dc..59f4477 100644 --- a/src/FlatFile.FixedLength/Implementation/FixedLengthFileMultiEngine.cs +++ b/src/FlatFile.FixedLength/Implementation/FixedLengthFileMultiEngine.cs @@ -104,7 +104,7 @@ internal FixedLengthFileMultiEngine( /// IEnumerable<T>. public IEnumerable GetRecords() where T : class, new() { - return !results.ContainsKey(typeof(T)) ? new List() : results[typeof(T)].Cast(); + return !results.ContainsKey(typeof (T)) ? new List() : results[typeof(T)].Cast(); } ///