Class AbstractNativeFileParser
Abstract base class that provides boilerplate implementation for native file parsers.
Deriving your file parser from this class will save you some implementation work. Provides a default implementation of the ParseNext() method. You can override the BeforeParsing(), DuringParsing() and AfterParsing() in your parser implementation in order to separate initialization and clean-up code from the core parsing code.
Implements
Inherited Members
Namespace: SdlSdl.FileTypeSupportFrameworkNativeApi
Assembly: Sdl.FileTypeSupport.Framework.Core.dll
Syntax
public abstract class AbstractNativeFileParser : AbstractNativeFileTypeComponent, INativeContentStreamMessageReporter, IBasicMessageReporter, INativeFileParser, INativeFileTypeComponent, IParser, IDisposable
Constructors
AbstractNativeFileParser()
Protected constructor that should only be called by derived classes
Declaration
protected AbstractNativeFileParser()
Properties
CurrentStage
The stage of processing that the parser has reached
Declaration
protected AbstractNativeFileParser.Stage CurrentStage { get; set; }
Property Value
Type | Description |
---|---|
AbstractNativeFileParserStage |
Output
Default implementation of the Output property
Declaration
public virtual INativeExtractionContentHandler Output { get; set; }
Property Value
Type | Description |
---|---|
INativeExtractionContentHandler |
Methods
AfterParsing()
The implementation of ParseNext() will call this method once, after parsing has been completed (which is indicated by DuringParsing() returning false).
Override this method to do clean-up work such as closing the file etc. once parsing is complete.
The default implementation does nothing.
Declaration
protected virtual void AfterParsing()
BeforeParsing()
The implementation of ParseNext() will call this method the very first time that ParseNext is called.
Override this method to perform setup work for the parsing such as initializing the state, opening the file to be parsed, etc.
The default implementation of this method does nothing.
Declaration
protected virtual void BeforeParsing()
Dispose()
Implements IDisposable. Just calls Dispose saying that this is an explicit disposal and tells the GC not to call the Finalizer.
Declaration
public void Dispose()
Dispose(bool)
Last change for the Parser to dispose manage and unmanged objects. It can be overriden by subclases.
Declaration
protected virtual void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
bool | disposing | indicates if the dispose is explicit or implicit (from GC) |
DuringParsing()
The implementation of ParseNext() will call this method to perform actual parsing of the file.
BeforeParsing() will always be called before this method.
Override this method to perform the parsing in suitably small chunks.
Returns true
as long as there is more content to be parsed.
Once this function returns false
, the AfterParsing() method
will be called once.
During parsing the implementation may call OnProgress(object, ProgressEventArgs) to report the current progress.
The default implementation returns false.
Declaration
protected virtual bool DuringParsing()
Returns
Type | Description |
---|---|
bool | True if there is more content to be parsed, false when parsing has been completed |
~AbstractNativeFileParser()
The distructor just calls Dispose with false parameter specifying this is a cakl from GC.
Declaration
protected ~AbstractNativeFileParser()
OnProgress(byte)
Helper method to set up the Progress event
Declaration
public void OnProgress(byte percent)
Parameters
Type | Name | Description |
---|---|---|
byte | percent |
OnProgress(object, ProgressEventArgs)
Helper method to fire the Progress event
Declaration
public virtual void OnProgress(object sender, ProgressEventArgs args)
Parameters
Type | Name | Description |
---|---|---|
object | sender | the event source |
ProgressEventArgs | args | progress value between 0 and 100 |
OutputText(string)
Helper method to output plain text
Declaration
public void OutputText(string text)
Parameters
Type | Name | Description |
---|---|---|
string | text |
ParseNext()
Default implementation that takes care of dividing the parsing into three stages, before parsing, during parsing, and after parsing, by calling the methods BeforeParsing(), DuringParsing(), and AfterParsing() that derived classes should normally override to do the setup, parsing, and clean-up work.
Derived classes do not need to override this method unless they need to add additional functionality outside of the three parsing implementation methods.
Declaration
public virtual bool ParseNext()
Returns
Type | Description |
---|---|
bool |
Events
Progress
Progress reporting events, typically attached to when a progress reporter is used
Declaration
public event EventHandler<ProgressEventArgs> Progress
Event Type
Type | Description |
---|---|
EventHandlerProgressEventArgs |