Class DsvDataReader
- Namespace
- Cuemon.Data
- Assembly
- Cuemon.Data.dll
Provides a way of reading a forward-only stream of rows from a DSV (Delimiter Separated Values) based data source. This class cannot be inherited.
public sealed class DsvDataReader : DataReader<string[]>, IDataReader, IDataRecord, IDisposable
- Inheritance
-
DataReader<String[]>DsvDataReader
- Implements
- Inherited Members
Constructors
DsvDataReader(StreamReader, String, Func<String, Object>, Action<DelimitedStringOptions>)
Initializes a new instance of the DsvDataReader class.
public DsvDataReader(StreamReader reader, string header = null, Func<string, object> parser = null, Action<DelimitedStringOptions> setup = null)
Parameters
reader
StreamReaderThe StreamReader object that contains the DSV data.
header
StringThe header defining the columns of the DSV data. Default is reading the first line of the
reader
.parser
Func<String, Object>The function delegate that returns a primitive object whose value is equivalent to the provided String value. Default is FromValueType().
setup
Action<DelimitedStringOptions>The FormattingOptions which may be configured.
Exceptions
- ArgumentException
header
cannot be empty or consist only of white-space characters -or-header
does not contain the Delimiter specified insetup
.- ArgumentNullException
reader
is null.
Properties
Delimiter
Gets the delimiter used to separate fields of this instance.
public string Delimiter { get; }
Property Value
- String
The delimiter used to separate fields of this instance.
Header
Gets the header that defines the field names of this instance.
public string[] Header { get; }
Property Value
- String[]
The header that defines the field names of this instance.
NullRead
Gets the value that indicates that no more rows exists.
protected override string[] NullRead { get; }
Property Value
- String[]
The value that indicates that no more rows exists.
Qualifier
Gets the qualifier that surrounds a field.
public string Qualifier { get; }
Property Value
- String
The qualifier that surrounds a field.
RowCount
Gets the currently processed row count of this instance.
public override int RowCount { get; protected set; }
Property Value
- Int32
The currently processed row count of this instance.
Remarks
This property is incremented when the invoked Read() method returns true
.
Methods
OnDisposeManagedResources()
Called when this object is being disposed by either Dispose() or Dispose(Boolean) having disposing
set to true
and Disposed is false
.
protected override void OnDisposeManagedResources()
Read()
Advances this instance to the next line of the DSV data source.
public override bool Read()
Returns
- Boolean
true
if there are more lines; otherwise,false
.
Exceptions
- ObjectDisposedException
This instance has been disposed.
ReadAsync()
Asynchronously advances this instance to the next line of the DSV data source.
public Task<bool> ReadAsync()
Returns
Exceptions
- ObjectDisposedException
This instance has been disposed.
ReadNext(String[])
Advances this instance to the next record.
protected override string[] ReadNext(string[] columns)
Parameters
columns
String[]