Class HapDocumentProvider
An implementation of IReadsAndWritesDocument which uses the HtmlAgilityPack (aka "HAP") HTML parsing library. See https://html-agility-pack.net/ and https://github.com/zzzprojects/html-agility-pack for more information.
Implements
Inherited Members
Namespace: ZptSharp.Dom
Assembly: ZptSharp.HtmlAgilityPack.dll
Syntax
public class HapDocumentProvider : DocumentReaderWriterBase<HapDocument>, IReadsAndWritesDocument
Properties
| Improve this Doc View SourceResolvableType
Gets the type of the current instance, for the purpose of future dependency resolution.
Declaration
public override Type ResolvableType { get; }
Property Value
Type | Description |
---|---|
System.Type |
Overrides
Remarks
Gets the type of the current instance, for the purpose of dependency resolution. This is not/should not be quite the same as System.Object.GetType(), because a derived implementation might not always be resolved as its precise type, it might be resolved as a less-derived base type.
Methods
| Improve this Doc View SourceCanReadWriteForFilename(String)
Gets whether or not the current instance may be used to read & write documents which have the specified filename.
Declaration
public override bool CanReadWriteForFilename(string filenameOrPath)
Parameters
Type | Name | Description |
---|---|---|
System.String | filenameOrPath | The filename of a ZPT document. |
Returns
Type | Description |
---|---|
System.Boolean |
|
Overrides
GetDocumentProtectedAsync(Stream, RenderingConfig, IDocumentSourceInfo, CancellationToken)
Implement this method in a derived class to perform custom logic related to reading a document from a stream.
Derived types should assume that the stream
& config
parameters have
been null-checked. Also, they should assume that the token
parameter does not request cancellation.
Declaration
protected override Task<IDocument> GetDocumentProtectedAsync(Stream stream, RenderingConfig config, IDocumentSourceInfo sourceInfo, CancellationToken token)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | stream | A stream containing the source of the document. |
RenderingConfig | config | Rendering configuration. |
IDocumentSourceInfo | sourceInfo | Information which identifies the source of the document. |
System.Threading.CancellationToken | token | An object used to cancel the operation if required. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<IDocument> | A task which provides the document which has been read. |
Overrides
Remarks
This implementation is not truly asynchronous, as the APIs involved do not provide async functionality.
WriteDocumentProtectedAsync(HapDocument, RenderingConfig, CancellationToken)
Implement this method in a derived class to perform custom logic related to writing a document to a stream.
Derived types should assume that the document
& config
parameters
have been null-checked. The document will also already be converted to HapDocument.
Finally, the token
parameter will have already been checked that it does not request cancellation.
Declaration
protected override Task<Stream> WriteDocumentProtectedAsync(HapDocument document, RenderingConfig config, CancellationToken token)
Parameters
Type | Name | Description |
---|---|---|
HapDocument | document | The document to write. |
RenderingConfig | config | Rendering configuration. |
System.Threading.CancellationToken | token | An object used to cancel the operation if required. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.IO.Stream> | A task which provides the output stream. |
Overrides
Remarks
This implementation ignores OmitXmlDeclaration, as would be expected. This is not an XML document format.