Class BaseSourceReader
- Namespace
- Dynamicweb.DataIntegration.Integration
- Assembly
- Dynamicweb.DataIntegration.dll
Placeholder base class for source readers. A source reader is the object a source provider returns from GetReader(Mapping); the job engine drains it row by row via IsDone() and GetNext() until the source table is exhausted.
public class BaseSourceReader : ISourceReader, IDisposable
- Inheritance
-
BaseSourceReader
- Implements
- Inherited Members
Remarks
This class provides no functionality — every member throws NotImplementedException, and the members are non-virtual so they cannot be overridden. It is kept for backwards compatibility only. When building a custom source provider, implement ISourceReader directly instead, or derive from BaseSqlReader when reading from a SQL database.
If existing code derives from this class, it must hide the members with new implementations and
re-declare ISourceReader on the derived class; otherwise calls made through the interface dispatch
to the throwing base implementations.
The reader contract: IsDone() is checked before each row; while it returns false,
GetNext() must return the next source row as a dictionary keyed by source column name.
The reader is disposed when the table has been read.
using Dynamicweb.DataIntegration.Integration;
using Dynamicweb.DataIntegration.Integration.Interfaces;
public sealed class MySourceReader : ISourceReader
{
private readonly IEnumerator<Dictionary<string, object>> _rows;
private bool _hasNext;
public MySourceReader(Mapping mapping)
{
_rows = ReadRows(mapping).GetEnumerator();
_hasNext = _rows.MoveNext();
}
public bool IsDone() => !_hasNext;
public Dictionary<string, object> GetNext()
{
var current = _rows.Current;
_hasNext = _rows.MoveNext();
return current;
}
public void Dispose() => _rows.Dispose();
private static IEnumerable<Dictionary<string, object>> ReadRows(Mapping mapping)
{
// Read from the actual source here, keyed by source column name.
yield return new Dictionary<string, object> { ["Id"] = 1, ["Name"] = "Example" };
}
}
Methods
Close()
Closes the reader. Not implemented in this base class — always throws NotImplementedException.
public void Close()
Exceptions
- NotImplementedException
Always thrown by this base implementation.
Dispose()
Releases resources used by the reader. Not implemented in this base class — always throws NotImplementedException.
public void Dispose()
Exceptions
- NotImplementedException
Always thrown by this base implementation.
GetNext()
Gets the next source row, keyed by source column name. Not implemented in this base class — always throws NotImplementedException.
public Dictionary<string, object> GetNext()
Returns
- Dictionary<string, object>
The next row of the source table.
Exceptions
- NotImplementedException
Always thrown by this base implementation.
IsDone()
Determines whether the reader has exhausted the source. Not implemented in this base class — always throws NotImplementedException.
public bool IsDone()
Returns
- bool
truewhen no more rows are available; otherwisefalse.
Exceptions
- NotImplementedException
Always thrown by this base implementation.