Show / Hide Table of Contents

# Class ServiceCollectionExtensions

##### Inheritance

System.Object
ServiceCollectionExtensions

###### Namespace: anybill.POS.Client.Extensions.Microsoft.DependencyInjection

###### Assembly: anybill.POS.Client.Microsoft.Extensions.DependencyInjection.dll

##### Syntax

    public static class ServiceCollectionExtensions

### Methods

#### AddAnybillClient(IServiceCollection, IAuthTokenProvider)

Registers the IAnybillClient as singleton.

##### Declaration

    public static IServiceCollection AddAnybillClient(this IServiceCollection services, IAuthTokenProvider authTokenProvider)

##### Parameters

Type | Name | Description
--- | --- | ---
Microsoft.Extensions.DependencyInjection.IServiceCollection | services | Service collection
IAuthTokenProvider | authTokenProvider | The token provider used for authentication.

##### Returns

Type | Description
--- | ---
Microsoft.Extensions.DependencyInjection.IServiceCollection | The service collection for chaining

##### Remarks

See AddAnybillClientFactory(IServiceCollection) on how to customize the behaviour of the IAnybillClient.

#### AddAnybillClient(IServiceCollection, IAuthTokenProvider, AnybillEnvironment)

Registers the IAnybillClient as singleton.

##### Declaration

    public static IServiceCollection AddAnybillClient(this IServiceCollection services, IAuthTokenProvider authTokenProvider, AnybillEnvironment anybillEnvironment)

##### Parameters

Type | Name | Description
--- | --- | ---
Microsoft.Extensions.DependencyInjection.IServiceCollection | services | Service collection
IAuthTokenProvider | authTokenProvider | The token provider used for authentication.
AnybillEnvironment | anybillEnvironment | The anybill environment to use.

##### Returns

Type | Description
--- | ---
Microsoft.Extensions.DependencyInjection.IServiceCollection | The service collection for chaining

##### Remarks

See AddAnybillClientFactory(IServiceCollection) on how to customize the behaviour of the IAnybillClient.

#### AddAnybillClient(IServiceCollection, IAuthTokenProvider, AnybillEnvironment, HttpClient)

Registers the IAnybillClient as singleton.

##### Declaration

    public static IServiceCollection AddAnybillClient(this IServiceCollection services, IAuthTokenProvider authTokenProvider, AnybillEnvironment anybillEnvironment, HttpClient httpClient)

##### Parameters

Type | Name | Description
--- | --- | ---
Microsoft.Extensions.DependencyInjection.IServiceCollection | services | Service collection
IAuthTokenProvider | authTokenProvider | The token provider used for authentication.
AnybillEnvironment | anybillEnvironment | The anybill environment to use.
System.Net.Http.HttpClient | httpClient | The custom http client to use.

##### Returns

Type | Description
--- | ---
Microsoft.Extensions.DependencyInjection.IServiceCollection | The service collection for chaining

##### Remarks

See AddAnybillClientFactory(IServiceCollection) on how to customize the behaviour of the IAnybillClient.

#### AddAnybillClient(IServiceCollection, Action<AnybillAuthenticationOptionsBuilder>)

Registers the IAnybillClient as singleton.

##### Declaration

    public static IServiceCollection AddAnybillClient(this IServiceCollection services, Action<AnybillAuthenticationOptionsBuilder> configureAuthentication)

##### Parameters

Type | Name | Description
--- | --- | ---
Microsoft.Extensions.DependencyInjection.IServiceCollection | services | Service collection
System.Action<AnybillAuthenticationOptionsBuilder> | configureAuthentication | Action to configure the DefaultAuthTokenProvider used for authentication.

##### Returns

Type | Description
--- | ---
Microsoft.Extensions.DependencyInjection.IServiceCollection | The service collection for chaining

##### Remarks

See AddAnybillClientFactory(IServiceCollection) on how to customize the behaviour of the IAnybillClient.

#### AddAnybillClient(IServiceCollection, Action<AnybillAuthenticationOptionsBuilder>, AnybillEnvironment)

Registers the IAnybillClient as singleton.

##### Declaration

    public static IServiceCollection AddAnybillClient(this IServiceCollection services, Action<AnybillAuthenticationOptionsBuilder> configureAuthentication, AnybillEnvironment anybillEnvironment)

##### Parameters

Type | Name | Description
--- | --- | ---
Microsoft.Extensions.DependencyInjection.IServiceCollection | services | Service collection
System.Action<AnybillAuthenticationOptionsBuilder> | configureAuthentication | Action to configure the DefaultAuthTokenProvider used for authentication.
AnybillEnvironment | anybillEnvironment | The anybill environment to use.

##### Returns

Type | Description
--- | ---
Microsoft.Extensions.DependencyInjection.IServiceCollection | The service collection for chaining

##### Remarks

See AddAnybillClientFactory(IServiceCollection) on how to customize the behaviour of the IAnybillClient.

#### AddAnybillClient(IServiceCollection, Action<AnybillAuthenticationOptionsBuilder>, AnybillEnvironment, HttpClient)

Registers the IAnybillClient as singleton.

##### Declaration

    public static IServiceCollection AddAnybillClient(this IServiceCollection services, Action<AnybillAuthenticationOptionsBuilder> configureAuthentication, AnybillEnvironment anybillEnvironment, HttpClient httpClient)

##### Parameters

Type | Name | Description
--- | --- | ---
Microsoft.Extensions.DependencyInjection.IServiceCollection | services | Service collection
System.Action<AnybillAuthenticationOptionsBuilder> | configureAuthentication | Action to configure the DefaultAuthTokenProvider used for authentication.
AnybillEnvironment | anybillEnvironment | The anybill environment to use.
System.Net.Http.HttpClient | httpClient | The custom http client to use.

##### Returns

Type | Description
--- | ---
Microsoft.Extensions.DependencyInjection.IServiceCollection | The service collection for chaining

##### Remarks

See AddAnybillClientFactory(IServiceCollection) on how to customize the behaviour of the IAnybillClient.

#### AddAnybillClientFactory(IServiceCollection)

##### Declaration

    public static IServiceCollection AddAnybillClientFactory(this IServiceCollection services)

##### Parameters

Type | Name | Description
--- | --- | ---
Microsoft.Extensions.DependencyInjection.IServiceCollection | services |

##### Returns

Type | Description
--- | ---
Microsoft.Extensions.DependencyInjection.IServiceCollection |

#### AddAnybillClientFactory(IServiceCollection, HttpClient)

Registers a default implementation of the IAnybillClientFactory as singleton.

##### Declaration

    public static IServiceCollection AddAnybillClientFactory(this IServiceCollection services, HttpClient httpClient)

##### Parameters

Type | Name | Description
--- | --- | ---
Microsoft.Extensions.DependencyInjection.IServiceCollection | services | Service collection
System.Net.Http.HttpClient | httpClient | The custom http client to use.

##### Returns

Type | Description
--- | ---
Microsoft.Extensions.DependencyInjection.IServiceCollection | The service collection for chaining

##### Remarks

Add custom implementations of IAnybillClientOptions, IDefaultAuthTokenProviderOptions or IAnybillEnvironmentOptions to customize the behaviour. Depends on the Microsoft.Extensions.Logging.ILoggerFactory for logging.