Table of Contents

Class DefaultDocumentFactory

Namespace
AngleSharp.Dom
Assembly
AngleSharp.dll

Provides the default content-type to document creation mapping.

public class DefaultDocumentFactory : IDocumentFactory
Inheritance
DefaultDocumentFactory
Implements
Inherited Members
Extension Methods

Constructors

DefaultDocumentFactory()

public DefaultDocumentFactory()

Methods

CreateAsync(IBrowsingContext, CreateDocumentOptions, CancellationToken)

Creates a new document from the given arguments using the Content-Type of the provided options.

public virtual Task<IDocument> CreateAsync(IBrowsingContext context, CreateDocumentOptions options, CancellationToken cancellationToken)

Parameters

context IBrowsingContext

The browsing context to use.

options CreateDocumentOptions

The options to consider.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<IDocument>

The task creating the document from the response.

CreateDefaultAsync(IBrowsingContext, CreateDocumentOptions, CancellationToken)

Creates the default document for the given options.

protected virtual Task<IDocument> CreateDefaultAsync(IBrowsingContext context, CreateDocumentOptions options, CancellationToken cancellationToken)

Parameters

context IBrowsingContext

The browsing context to use.

options CreateDocumentOptions

The options to consider.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<IDocument>

The task creating the document from the response.

LoadHtmlAsync(IBrowsingContext, CreateDocumentOptions, CancellationToken)

Loads the response as an HTML document.

protected static Task<IDocument> LoadHtmlAsync(IBrowsingContext context, CreateDocumentOptions options, CancellationToken cancellationToken)

Parameters

context IBrowsingContext
options CreateDocumentOptions
cancellationToken CancellationToken

Returns

Task<IDocument>

LoadTextAsync(IBrowsingContext, CreateDocumentOptions, CancellationToken)

Loads the response as a plain text (formatted as HTML) document.

protected static Task<IDocument> LoadTextAsync(IBrowsingContext context, CreateDocumentOptions options, CancellationToken cancellationToken)

Parameters

context IBrowsingContext
options CreateDocumentOptions
cancellationToken CancellationToken

Returns

Task<IDocument>

Register(string, Creator)

Registers a new creator for the specified content-type. Throws an exception if another creator for the given content-type is already added.

public virtual void Register(string contentType, DefaultDocumentFactory.Creator creator)

Parameters

contentType string

The content-type value.

creator DefaultDocumentFactory.Creator

The creator to invoke.

Unregister(string)

Unregisters an existing creator for the given content-type.

public virtual DefaultDocumentFactory.Creator? Unregister(string contentType)

Parameters

contentType string

The content-type value.

Returns

DefaultDocumentFactory.Creator

The registered creator, if any.