Class BatchProcessor
- Namespace
- EDIParser
- Assembly
- EDIParser.dll
Processes EDI messages from a stream and raises an event as each segment is read.
public sealed class BatchProcessor
- Inheritance
-
BatchProcessor
- Inherited Members
Remarks
The processor supports reading an entire stream or processing a limited range through the Limit(long, long) method.
When the parser's segment separator is a carriage-return and line-feed sequence, the stream is processed one line at a time. For other single-character segment separators, the stream is processed character by character.
Segment collection access is one-based, consistent with the original parser API.
Constructors
BatchProcessor(Parser, Stream)
Initializes a new instance of the BatchProcessor class.
public BatchProcessor(Parser parser, Stream stream)
Parameters
parserParserThe parser used to parse each EDI segment read from the stream.
streamStreamThe readable stream containing the EDI data to process.
Exceptions
- ArgumentNullException
Thrown when
parserorstreamis null.
Properties
ProcessingStatus
Gets the current batch-processing status.
public BatchProcessor.ProcessingStatuses ProcessingStatus { get; }
Property Value
- BatchProcessor.ProcessingStatuses
ProcessingComplete when processing has reached the end of the requested input; otherwise, ProcessingPending.
Methods
Limit(long, long)
Limits processing to a specified starting position and maximum count.
public void Limit(long seekPosition, long seekCount)
Parameters
seekPositionlongThe zero-based stream or line position at which processing begins.
seekCountlongThe maximum number of segments or lines to process. A value of zero indicates that no count limit is applied.
Remarks
For carriage-return and line-feed separated input,
seekPosition is interpreted as a line position.
For character-delimited input, it is interpreted as a byte position
within the stream.
Process()
Processes EDI data from the configured stream.
public void Process()
Remarks
When no processing limit has been configured, processing begins at the current stream position and continues until the end of the stream.
When the parser uses a carriage-return and line-feed segment separator, the input is processed line by line. Otherwise, the input is processed by searching for the configured segment-separator character.
The Reading event is raised after each parsed segment.
Events
Reading
Occurs after a segment has been read and parsed from the input stream.
public event BatchProcessor.ReadingEventHandler? Reading