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
IBrowsingContextThe browsing context to use.
options
CreateDocumentOptionsThe options to consider.
cancellationToken
CancellationTokenThe cancellation token.
Returns
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
IBrowsingContextThe browsing context to use.
options
CreateDocumentOptionsThe options to consider.
cancellationToken
CancellationTokenThe cancellation token.
Returns
LoadHtmlAsync(IBrowsingContext, CreateDocumentOptions, CancellationToken)
Loads the response as an HTML document.
protected static Task<IDocument> LoadHtmlAsync(IBrowsingContext context, CreateDocumentOptions options, CancellationToken cancellationToken)
Parameters
context
IBrowsingContextoptions
CreateDocumentOptionscancellationToken
CancellationToken
Returns
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
IBrowsingContextoptions
CreateDocumentOptionscancellationToken
CancellationToken
Returns
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
stringThe content-type value.
creator
DefaultDocumentFactory.CreatorThe creator to invoke.
Unregister(string)
Unregisters an existing creator for the given content-type.
public virtual DefaultDocumentFactory.Creator? Unregister(string contentType)
Parameters
contentType
stringThe content-type value.
Returns
- DefaultDocumentFactory.Creator
The registered creator, if any.