Class FileHelperStringSource<TOutput>
A dataflow worker that reads delimited (e.g. CSV) or fixed format data rows from one or more strings, and sends them to a downstream worker.
Please see CSV Delimited and Fixed Format for how to specify the data format. Internally, this worker uses the http://www.filehelpers.net/ library to read the data, specifically the FileHelperAsyncEngine class.
Implements
Inherited Members
Namespace: actionETL.FileHelper
Assembly: actionETL.dll
Syntax
[CLSCompliant(false)]
public class FileHelperStringSource<TOutput> : WorkerBase<FileHelperStringSource<TOutput>>, IDisposeOnFinished where TOutput : class
Type Parameters
| Name | Description |
|---|---|
| TOutput | A class that defines the format, columns, separators, column order etc. of the source data, as well as the type of the rows that will be passed to the downstream worker. |
Constructors
FileHelperStringSource(WorkerParent, String, IEnumerable<String>)
Initializes a new instance of the FileHelperStringSource<TOutput> dataflow worker, that reads delimited (e.g. CSV) or fixed format data rows from one or more strings, and outputs them to the downstream worker.
Declaration
public FileHelperStringSource(WorkerParent workerParent, string workerName, IEnumerable<string> stringsData)
Parameters
| Type | Name | Description |
|---|---|---|
| WorkerParent | workerParent | The parent worker or worker system that the new child worker will be added to. Cannot be |
| String | workerName | Name of the worker.
Set to a prefix plus a trailing
While less useful, set to
The name cannot otherwise contain |
| IEnumerable<String> | stringsData | One or more strings. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException |
|
| ArgumentNullException |
|
| InvalidOperationException |
|
FileHelperStringSource(WorkerParent, String, Func<Boolean>, IEnumerable<String>)
Initializes a new instance of the FileHelperStringSource<TOutput> dataflow worker, that reads delimited (e.g. CSV) or fixed format data rows from one or more strings, and outputs them to the downstream worker.
Declaration
public FileHelperStringSource(WorkerParent workerParent, string workerName, Func<bool> isStartableFunc, IEnumerable<string> stringsData)
Parameters
| Type | Name | Description |
|---|---|---|
| WorkerParent | workerParent | The parent worker or worker system that the new child worker will be added to. Cannot be |
| String | workerName | Name of the worker.
Set to a prefix plus a trailing
While less useful, set to
The name cannot otherwise contain |
| Func<Boolean> | isStartableFunc | Function to calculate the worker start constraint; it should return |
| IEnumerable<String> | stringsData | One or more strings. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException |
|
| ArgumentNullException |
|
| InvalidOperationException |
|
FileHelperStringSource(WorkerParent, String, Func<Boolean>, String)
Initializes a new instance of the FileHelperStringSource<TOutput> dataflow worker, that reads delimited (e.g. CSV) or fixed format data rows from a string, and outputs them to the downstream worker.
Declaration
public FileHelperStringSource(WorkerParent workerParent, string workerName, Func<bool> isStartableFunc, string stringData)
Parameters
| Type | Name | Description |
|---|---|---|
| WorkerParent | workerParent | The parent worker or worker system that the new child worker will be added to. Cannot be |
| String | workerName | Name of the worker.
Set to a prefix plus a trailing
While less useful, set to
The name cannot otherwise contain |
| Func<Boolean> | isStartableFunc | Function to calculate the worker start constraint; it should return |
| String | stringData | The string data. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException |
|
| ArgumentNullException |
|
| InvalidOperationException |
|
FileHelperStringSource(WorkerParent, String, String)
Initializes a new instance of the FileHelperStringSource<TOutput> dataflow worker, that reads delimited (e.g. CSV) or fixed format data rows from a string, and outputs them to the downstream worker.
Declaration
public FileHelperStringSource(WorkerParent workerParent, string workerName, string stringData)
Parameters
| Type | Name | Description |
|---|---|---|
| WorkerParent | workerParent | The parent worker or worker system that the new child worker will be added to. Cannot be |
| String | workerName | Name of the worker.
Set to a prefix plus a trailing
While less useful, set to
The name cannot otherwise contain |
| String | stringData | The string data. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException |
|
| ArgumentNullException |
|
| InvalidOperationException |
|
Properties
Engine
Gets the underlying FileHelpers FileHelperAsyncEngine instance. Use this for customizing the data transfer, such as setting the text encoding and preprocess the data records. See CSV Delimited and Fixed Format for details.
Note: Retrieving and inspecting this property is thread-safe,
but modifying the Engine state is not thread-safe, and should only
be done from a single thread, before the worker has started.
Declaration
public FileHelperAsyncEngine<TOutput> Engine { get; }
Property Value
| Type | Description |
|---|---|
| FileHelpers.FileHelperAsyncEngine<TOutput> | The FileHelpers engine instance. |
Remarks
Note that in rare cases, and only when using non-C# .NET languages, direct use of
the Engine property can fail with a compile time error since the underlying
FileHelpers library class (FileHelperAsyncEngine) is not CLS compliant (warning CS3003).
ErrorOutput
Gets the error output port for sending error rows to logging and an optional downstream worker.
Declaration
public ErrorOutputPort<StringRowErrors> ErrorOutput { get; }
Property Value
| Type | Description |
|---|---|
| ErrorOutputPort<StringRowErrors> |
Output
Gets the output port for sending rows to the downstream worker.
Declaration
public OutputPort<TOutput> Output { get; }
Property Value
| Type | Description |
|---|---|
| OutputPort<TOutput> |
StringData
Sets the string data. Overrides any StringsData setting. Cannot be set after the worker has started running.
Note: This property is thread-safe.
Declaration
public string StringData { set; }
Property Value
| Type | Description |
|---|---|
| String |
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | Cannot set the value after the worker has started running. |
StringsData
Sets the strings data. Overrides any StringData setting. Cannot be set after the worker has started running.
Note: This property is thread-safe.
Declaration
public IEnumerable<string> StringsData { set; }
Property Value
| Type | Description |
|---|---|
| IEnumerable<String> | The strings data. |
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | Cannot set the value after the worker has started running. |
Methods
RunAsync()
This method can be overridden to add custom functionality to the derived worker that runs before
and after the row processing. In this case, the base class base.RunAsync() must
be called for the worker to function correctly.
Typically, this worker is used without overriding this method.
Declaration
protected override Task<OutcomeStatus> RunAsync()
Returns
| Type | Description |
|---|---|
| Task<OutcomeStatus> | A |