Table of Contents

Class ConfigurationExtensions

Namespace
AngleSharp
Assembly
AngleSharp.dll

A set of useful extensions for Configuration (or derived) objects.

public static class ConfigurationExtensions
Inheritance
ConfigurationExtensions
Inherited Members

Methods

Has<TService>(IConfiguration)

Checks if the configuration holds any references to the given service.

public static bool Has<TService>(this IConfiguration configuration)

Parameters

configuration IConfiguration

The configuration to examine.

Returns

bool

True if any service / creators are found, otherwise false.

Type Parameters

TService

The type of service to check for.

With(IConfiguration, IEnumerable<object>)

Returns a new configuration that includes the given services.

public static IConfiguration With(this IConfiguration configuration, IEnumerable<object> services)

Parameters

configuration IConfiguration

The configuration to extend.

services IEnumerable<object>

The services to register.

Returns

IConfiguration

The new instance with the services.

With(IConfiguration, object)

Returns a new configuration that includes the given service.

public static IConfiguration With(this IConfiguration configuration, object service)

Parameters

configuration IConfiguration

The configuration to extend.

service object

The service to register.

Returns

IConfiguration

The new instance with the service.

WithCulture(IConfiguration, CultureInfo)

Returns a new configuration that uses the given culture. Providing null will reset the culture to the default one.

public static IConfiguration WithCulture(this IConfiguration configuration, CultureInfo culture)

Parameters

configuration IConfiguration

The configuration to extend.

culture CultureInfo

The culture to set.

Returns

IConfiguration

The new instance with the culture being set.

WithCulture(IConfiguration, string)

Returns a new configuration that uses the culture with the provided name.

public static IConfiguration WithCulture(this IConfiguration configuration, string name)

Parameters

configuration IConfiguration

The configuration to extend.

name string

The name of the culture to set.

Returns

IConfiguration

The new instance with the culture being set.

WithDefaultCookies(IConfiguration)

Registers the default cookie service if no other cookie service has been registered yet.

public static IConfiguration WithDefaultCookies(this IConfiguration configuration)

Parameters

configuration IConfiguration

The configuration to extend.

Returns

IConfiguration

The new instance with the service.

WithDefaultLoader(IConfiguration, LoaderOptions?)

Registers the default loader service, if no other loader has been registered yet.

public static IConfiguration WithDefaultLoader(this IConfiguration configuration, LoaderOptions? setup = null)

Parameters

configuration IConfiguration

The configuration to extend.

setup LoaderOptions

Configuration for the loader service.

Returns

IConfiguration

The new configuration with the service.

WithLocaleBasedEncoding(IConfiguration)

Registeres the default encoding determination algorithm, as specified by the W3C.

public static IConfiguration WithLocaleBasedEncoding(this IConfiguration configuration)

Parameters

configuration IConfiguration

The configuration to extend.

Returns

IConfiguration

The new instance with the service.

WithMetaRefresh(IConfiguration, Predicate<Url>?)

Registeres a handler to include the meta data refresh.

public static IConfiguration WithMetaRefresh(this IConfiguration configuration, Predicate<Url>? shouldRefresh = null)

Parameters

configuration IConfiguration

The configuration to extend.

shouldRefresh Predicate<Url>

The optional callback.

Returns

IConfiguration

The new instance with the service.

WithOnly<TService>(IConfiguration, Func<IBrowsingContext, TService>)

Returns a new configuration that includes only the given service creator, excluding other instances or instance creators for the same service.

public static IConfiguration WithOnly<TService>(this IConfiguration configuration, Func<IBrowsingContext, TService> creator)

Parameters

configuration IConfiguration

The configuration to extend.

creator Func<IBrowsingContext, TService>

The service creator to include.

Returns

IConfiguration

The new instance with only the given service.

Type Parameters

TService

The service to include exclusively.

WithOnly<TService>(IConfiguration, TService)

Returns a new configuration that includes only the given service, excluding other instances or instance creators for the same service.

public static IConfiguration WithOnly<TService>(this IConfiguration configuration, TService service)

Parameters

configuration IConfiguration

The configuration to extend.

service TService

The service to include.

Returns

IConfiguration

The new instance with only the given service.

Type Parameters

TService

The service to include exclusively.

With<TService>(IConfiguration, Func<IBrowsingContext, TService>)

Returns a new configuration that includes the given service creator.

public static IConfiguration With<TService>(this IConfiguration configuration, Func<IBrowsingContext, TService> creator)

Parameters

configuration IConfiguration

The configuration to extend.

creator Func<IBrowsingContext, TService>

The creator to register.

Returns

IConfiguration

The new instance with the services.

Type Parameters

TService

The type of service to create.

Without(IConfiguration, IEnumerable<object>)

Returns a new configuration that excludes the given services.

public static IConfiguration Without(this IConfiguration configuration, IEnumerable<object> services)

Parameters

configuration IConfiguration

The configuration to extend.

services IEnumerable<object>

The services to unregister.

Returns

IConfiguration

The new instance without the services.

Without(IConfiguration, object)

Returns a new configuration that excludes the given service.

public static IConfiguration Without(this IConfiguration configuration, object service)

Parameters

configuration IConfiguration

The configuration to extend.

service object

The service to unregister.

Returns

IConfiguration

The new instance without the service.

Without<TService>(IConfiguration)

Returns a new configuration that excludes the given service creator.

public static IConfiguration Without<TService>(this IConfiguration configuration)

Parameters

configuration IConfiguration

The configuration to extend.

Returns

IConfiguration

The new instance without the services.

Type Parameters

TService

The type of service to remove.