Class AngleSharpDocumentProvider
An implementation of IReadsAndWritesDocument which uses the AngleSharp HTML parsing library. See https://anglesharp.github.io/ for more information.
Implements
Inherited Members
Namespace: ZptSharp.Dom
Assembly: ZptSharp.AngleSharp.dll
Syntax
public class AngleSharpDocumentProvider : DocumentReaderWriterBase<AngleSharpDocument>, IReadsAndWritesDocument
Remarks
Please note that when using GetDocumentProtectedAsync(Stream, RenderingConfig, IDocumentSourceInfo, CancellationToken), this implementation ignores the DocumentEncoding. This is because AngleSharp will always automatically detect the encoding from the document; there is no way to specify the encoding externally. When writing a document using WriteDocumentProtectedAsync(AngleSharpDocument, RenderingConfig, CancellationToken), the configured encoding is honoured.
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 ignores DocumentEncoding; AngleSharp always detects the document encoding from the HTML document itself. It is strongly advised to use UTF-8.
WriteDocumentProtectedAsync(AngleSharpDocument, 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 AngleSharpDocument.
Finally, the token
parameter will have already been checked that it does not request cancellation.
Declaration
protected override Task<Stream> WriteDocumentProtectedAsync(AngleSharpDocument document, RenderingConfig config, CancellationToken token)
Parameters
Type | Name | Description |
---|---|---|
AngleSharpDocument | 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.