C# Class SIL.FieldWorks.FDO.Infrastructure.Impl.ElementReader

Responsible to read a file which has a sequence of similar elements and pass a byte array of each element to a delgate for processing. Use low-level byte array methods, overlapping file read with parsing the file and calling the delegate. The expectation is that, after some unspecified header material, the file consists of a sequence of elements, all with the same tag (e.g., "rt" elements in FieldWorks XML backend). Following the last we expect a close tag for the containing element, e.g., "/languageProjet" in Fieldworks. These two tags can be configured so the class can be used in other ways. Enhance JohnT: Experiments on Websters indicate we're spending appreciable time on the parsing and calling the delegate. We could potentially do the parsing and delegate calling on different threads, perhaps even (since the order of calling delegates on different elements does not matter) split the parsing over multiple threads.
Inheritance: IDisposable
显示文件 Open project: sillsdev/FieldWorks Class Usage Examples

Public Methods

Method Description
Dispose ( ) : void
ElementReader ( string openingMarker, string finalClosingTag, string pathname, Action outputHandler ) : System
Run ( ) : void

Protected Methods

Method Description
Dispose ( bool fDisposing ) : void

Private Methods

Method Description
AdvanceToMarkerElement ( ) : bool

Advance input, copying characters read to m_output if it is non-null, until we have successfully read the target marker, or reached EOF. Return true if we found it. Assumes m_marker is at least two characters. Also expects it to be an XML element marker, or at least that it's first character does not recur in the marker.

ElementReader ( string openingMarker, string finalClosingTag, string pathname, Action outputHandler, int bufferSize ) : System
EndMarkerFound ( ) : bool
FillBuffer ( ) : void

Get some more data to process. Initially, buffer[m_nextReadBuffer] is in state non-in-use, and we initiate a read into it. After that, we should typically find that buffer[m_nextReadBuffer] is in state being-read, and we wait for that read to finish. Then we initiate a new read on the next buffer, asssuming it is not in use.

GetRtElement ( ) : bool

Called when we have just read the input marker. Advances to the start of closing tag or just after the next element.

More ( ) : bool
NextBuffer ( int bufIndex ) : int
StartReadingBuffer ( ) : void

Method Details

Dispose() public method

public Dispose ( ) : void
return void

Dispose() protected method

protected Dispose ( bool fDisposing ) : void
fDisposing bool
return void

ElementReader() public method

public ElementReader ( string openingMarker, string finalClosingTag, string pathname, Action outputHandler ) : System
openingMarker string
finalClosingTag string
pathname string
outputHandler Action
return System

Run() public method

public Run ( ) : void
return void