Last active
December 15, 2015 04:59
-
-
Save joshgo/5205773 to your computer and use it in GitHub Desktop.
CsvHelper - ICsvParser implementation using Lumenworks Lumenworks is a very efficient and very reliable CsvParser.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class LumenICsvPaser : CsvHelper.ICsvParser | |
| { | |
| private LumenWorks.Framework.IO.Csv.CsvReader _reader = null; | |
| public LumenICsvPaser(System.IO.TextReader stream) : this(stream, new CsvConfiguration()) | |
| { | |
| } | |
| public LumenICsvPaser(System.IO.TextReader stream, CsvConfiguration config) | |
| { | |
| _reader = new LumenWorks.Framework.IO.Csv.CsvReader(stream, false, config.Delimiter[0], config.BufferSize); | |
| Configuration = config; | |
| } | |
| public void Dispose() | |
| { | |
| if (_reader != null) | |
| { | |
| _reader.Dispose(); | |
| _reader = null; | |
| } | |
| } | |
| public CsvConfiguration Configuration { get; private set; } | |
| public int FieldCount { get { return _reader.FieldCount; } } | |
| public long CharPosition { get { throw new NotImplementedException(); } } | |
| public long BytePosition { get { throw new NotImplementedException(); } } | |
| public int Row { get { return (int) _reader.CurrentRecordIndex; } } | |
| public string RawRecord { get { return _reader.GetCurrentRawData(); } } | |
| public string[] Read() | |
| { | |
| if(!_reader.ReadNextRecord()) | |
| return null; | |
| string[] buffer = new string[FieldCount]; | |
| _reader.CopyCurrentRecordTo(buffer); | |
| return buffer; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment