Table of Contents

Class ServiceCollectionExtensions

Namespace
TypedRest
Assembly
TypedRest.dll

Provides extension methods for IServiceCollection.

public static class ServiceCollectionExtensions
Inheritance
ServiceCollectionExtensions
Inherited Members

Methods

AddBasicAuth(IHttpClientBuilder, Action<NetworkCredential>)

Adds HTTP Basic authentication.

public static IHttpClientBuilder AddBasicAuth(this IHttpClientBuilder builder, Action<NetworkCredential> configureCredentials)

Parameters

builder IHttpClientBuilder

The builder to apply the configuration to.

configureCredentials Action<NetworkCredential>

A delegate that is used to configure NetworkCredential.

Returns

IHttpClientBuilder

AddBasicAuth(IHttpClientBuilder, ICredentials)

Adds HTTP Basic authentication.

public static IHttpClientBuilder AddBasicAuth(this IHttpClientBuilder builder, ICredentials credentials)

Parameters

builder IHttpClientBuilder

The builder to apply the configuration to.

credentials ICredentials

A credential provider. Will be queried using BaseAddress as the uri and "Basic" as the authType.

Returns

IHttpClientBuilder

AddTypedRest(IServiceCollection, Uri)

Registers EntryEndpoint for dependency injection.

public static IHttpClientBuilder AddTypedRest(this IServiceCollection services, Uri uri)

Parameters

services IServiceCollection

The IServiceCollection.

uri Uri

The base URI of the REST API. Missing trailing slash will be appended automatically.

Returns

IHttpClientBuilder

An IHttpClientBuilder that can be used to configure the underlying HttpClient.

AddTypedRest<TEndpoint>(IServiceCollection, Uri)

Registers a type derived from EntryEndpoint for dependency injection.

public static IHttpClientBuilder AddTypedRest<TEndpoint>(this IServiceCollection services, Uri uri) where TEndpoint : EntryEndpoint

Parameters

services IServiceCollection

The IServiceCollection.

uri Uri

The base URI of the REST API. Missing trailing slash will be appended automatically.

Returns

IHttpClientBuilder

An IHttpClientBuilder that can be used to configure the underlying HttpClient.

Type Parameters

TEndpoint

The type of the EntryEndpoint. Must provide a constructor that accepts an HttpClient.

AddTypedRest<TInterface, TEndpoint>(IServiceCollection, Uri)

Registers a type derived from EntryEndpoint for dependency injection.

public static IHttpClientBuilder AddTypedRest<TInterface, TEndpoint>(this IServiceCollection services, Uri uri) where TInterface : class where TEndpoint : EntryEndpoint, TInterface

Parameters

services IServiceCollection

The IServiceCollection.

uri Uri

The base URI of the REST API. Missing trailing slash will be appended automatically.

Returns

IHttpClientBuilder

An IHttpClientBuilder that can be used to configure the underlying HttpClient.

Type Parameters

TInterface

The interface to register.

TEndpoint

The type of the EntryEndpoint. Must provide a constructor that accepts an HttpClient.