Show / Hide Table of Contents

Class AngleSharpDocumentProvider

An implementation of IReadsAndWritesDocument which uses the AngleSharp HTML parsing library. See https://anglesharp.github.io/ for more information.

Inheritance
System.Object
DocumentReaderWriterBase<AngleSharpDocument>
AngleSharpDocumentProvider
Implements
IReadsAndWritesDocument
Inherited Members
DocumentReaderWriterBase<AngleSharpDocument>.GetDocumentAsync(Stream, RenderingConfig, IDocumentSourceInfo, CancellationToken)
DocumentReaderWriterBase<AngleSharpDocument>.WriteDocumentAsync(IDocument, RenderingConfig, CancellationToken)
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
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 Source

ResolvableType

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
ZptSharp.Dom.DocumentReaderWriterBase<ZptSharp.Dom.AngleSharpDocument>.ResolvableType
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 Source

CanReadWriteForFilename(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

true, if this instance maybe used, false otherwise.

Overrides
ZptSharp.Dom.DocumentReaderWriterBase<ZptSharp.Dom.AngleSharpDocument>.CanReadWriteForFilename(System.String)
| Improve this Doc View Source

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
ZptSharp.Dom.DocumentReaderWriterBase<ZptSharp.Dom.AngleSharpDocument>.GetDocumentProtectedAsync(System.IO.Stream, ZptSharp.Config.RenderingConfig, ZptSharp.Rendering.IDocumentSourceInfo, System.Threading.CancellationToken)
Remarks

This implementation ignores DocumentEncoding; AngleSharp always detects the document encoding from the HTML document itself. It is strongly advised to use UTF-8.

| Improve this Doc View Source

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
ZptSharp.Dom.DocumentReaderWriterBase<ZptSharp.Dom.AngleSharpDocument>.WriteDocumentProtectedAsync(ZptSharp.Dom.AngleSharpDocument, ZptSharp.Config.RenderingConfig, System.Threading.CancellationToken)
Remarks

This implementation ignores OmitXmlDeclaration, as would be expected. This is not an XML document format.

Implements

IReadsAndWritesDocument
  • Improve this Doc
  • View Source
In This Article
Back to top Generated by DocFX