HttpClientBuilderExtensions.AddTypedClient Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
AddTypedClient<TClient,TImplementation>(IHttpClientBuilder) |
Configures a binding between the |
AddTypedClient<TClient>(IHttpClientBuilder) |
Configures a binding between the |
AddTypedClient<TClient>(IHttpClientBuilder, Func<HttpClient,IServiceProvider,TClient>) |
Configures a binding between the |
AddTypedClient<TClient>(IHttpClientBuilder, Func<HttpClient,TClient>) |
Configures a binding between the |
AddTypedClient<TClient,TImplementation>(IHttpClientBuilder)
Configures a binding between the TClient
type and the named HttpClient
associated with the IHttpClientBuilder. The created instances will be of type
TImplementation
.
public:
generic <typename TClient, typename TImplementation>
where TClient : class where TImplementation : class, TClient[System::Runtime::CompilerServices::Extension]
static Microsoft::Extensions::DependencyInjection::IHttpClientBuilder ^ AddTypedClient(Microsoft::Extensions::DependencyInjection::IHttpClientBuilder ^ builder);
public static Microsoft.Extensions.DependencyInjection.IHttpClientBuilder AddTypedClient<TClient,TImplementation> (this Microsoft.Extensions.DependencyInjection.IHttpClientBuilder builder) where TClient : class where TImplementation : class, TClient;
static member AddTypedClient : Microsoft.Extensions.DependencyInjection.IHttpClientBuilder -> Microsoft.Extensions.DependencyInjection.IHttpClientBuilder (requires 'Client : null)
<Extension()>
Public Function AddTypedClient(Of TClient As Class, TImplementation As Class) (builder As IHttpClientBuilder) As IHttpClientBuilder
Type Parameters
- TClient
The declared type of the typed client. They type specified will be registered in the service collection as a transient service. See ITypedHttpClientFactory<TClient> for more details about authoring typed clients.
- TImplementation
The implementation type of the typed client. The type specified by will be instantiated by the ITypedHttpClientFactory<TClient>.
Parameters
- builder
- IHttpClientBuilder
The IHttpClientBuilder.
Returns
Remarks
TClient
instances constructed with the appropriate HttpClient can be retrieved from GetService(Type) (and related methods) by providing TClient
as the service type.
Calling AddTypedClient<TClient,TImplementation>(IHttpClientBuilder) will register a typed client binding that creates TImplementation
using the ITypedHttpClientFactory<TClient>.
The typed client's service dependencies will be resolved from the same service provider that is used to resolve the typed client. It is not possible to access services from the scope bound to the message handler, which is managed independently.
Applies to
AddTypedClient<TClient>(IHttpClientBuilder)
Configures a binding between the TClient
type and the named HttpClient
associated with the IHttpClientBuilder.
public:
generic <typename TClient>
where TClient : class[System::Runtime::CompilerServices::Extension]
static Microsoft::Extensions::DependencyInjection::IHttpClientBuilder ^ AddTypedClient(Microsoft::Extensions::DependencyInjection::IHttpClientBuilder ^ builder);
public static Microsoft.Extensions.DependencyInjection.IHttpClientBuilder AddTypedClient<TClient> (this Microsoft.Extensions.DependencyInjection.IHttpClientBuilder builder) where TClient : class;
static member AddTypedClient : Microsoft.Extensions.DependencyInjection.IHttpClientBuilder -> Microsoft.Extensions.DependencyInjection.IHttpClientBuilder (requires 'Client : null)
<Extension()>
Public Function AddTypedClient(Of TClient As Class) (builder As IHttpClientBuilder) As IHttpClientBuilder
Type Parameters
- TClient
The type of the typed client. The type specified will be registered in the service collection as a transient service. See ITypedHttpClientFactory<TClient> for more details about authoring typed clients.
Parameters
- builder
- IHttpClientBuilder
The IHttpClientBuilder.
Returns
Remarks
TClient
instances constructed with the appropriate HttpClient can be retrieved from GetService(Type) (and related methods) by providing TClient
as the service type.
Calling AddTypedClient<TClient>(IHttpClientBuilder) will register a typed client binding that creates TClient
using the ITypedHttpClientFactory<TClient>.
The typed client's service dependencies will be resolved from the same service provider that is used to resolve the typed client. It is not possible to access services from the scope bound to the message handler, which is managed independently.
Applies to
AddTypedClient<TClient>(IHttpClientBuilder, Func<HttpClient,IServiceProvider,TClient>)
Configures a binding between the TClient
type and the named HttpClient
associated with the IHttpClientBuilder.
public:
generic <typename TClient>
where TClient : class[System::Runtime::CompilerServices::Extension]
static Microsoft::Extensions::DependencyInjection::IHttpClientBuilder ^ AddTypedClient(Microsoft::Extensions::DependencyInjection::IHttpClientBuilder ^ builder, Func<System::Net::Http::HttpClient ^, IServiceProvider ^, TClient> ^ factory);
public static Microsoft.Extensions.DependencyInjection.IHttpClientBuilder AddTypedClient<TClient> (this Microsoft.Extensions.DependencyInjection.IHttpClientBuilder builder, Func<System.Net.Http.HttpClient,IServiceProvider,TClient> factory) where TClient : class;
static member AddTypedClient : Microsoft.Extensions.DependencyInjection.IHttpClientBuilder * Func<System.Net.Http.HttpClient, IServiceProvider, 'Client (requires 'Client : null)> -> Microsoft.Extensions.DependencyInjection.IHttpClientBuilder (requires 'Client : null)
<Extension()>
Public Function AddTypedClient(Of TClient As Class) (builder As IHttpClientBuilder, factory As Func(Of HttpClient, IServiceProvider, TClient)) As IHttpClientBuilder
Type Parameters
- TClient
The type of the typed client. They type specified will be registered in the service collection as a transient service.
Parameters
- builder
- IHttpClientBuilder
The IHttpClientBuilder.
- factory
- Func<HttpClient,IServiceProvider,TClient>
A factory function that will be used to construct the typed client.
Returns
Remarks
TClient
instances constructed with the appropriate HttpClient can be retrieved from GetService(Type) (and related methods) by providing TClient
as the service type.
Calling AddTypedClient<TClient>(IHttpClientBuilder, Func<HttpClient,IServiceProvider,TClient>) will register a typed client binding that creates TClient
using the provided factory function.
Applies to
AddTypedClient<TClient>(IHttpClientBuilder, Func<HttpClient,TClient>)
Configures a binding between the TClient
type and the named HttpClient
associated with the IHttpClientBuilder.
public:
generic <typename TClient>
where TClient : class[System::Runtime::CompilerServices::Extension]
static Microsoft::Extensions::DependencyInjection::IHttpClientBuilder ^ AddTypedClient(Microsoft::Extensions::DependencyInjection::IHttpClientBuilder ^ builder, Func<System::Net::Http::HttpClient ^, TClient> ^ factory);
public static Microsoft.Extensions.DependencyInjection.IHttpClientBuilder AddTypedClient<TClient> (this Microsoft.Extensions.DependencyInjection.IHttpClientBuilder builder, Func<System.Net.Http.HttpClient,TClient> factory) where TClient : class;
static member AddTypedClient : Microsoft.Extensions.DependencyInjection.IHttpClientBuilder * Func<System.Net.Http.HttpClient, 'Client (requires 'Client : null)> -> Microsoft.Extensions.DependencyInjection.IHttpClientBuilder (requires 'Client : null)
<Extension()>
Public Function AddTypedClient(Of TClient As Class) (builder As IHttpClientBuilder, factory As Func(Of HttpClient, TClient)) As IHttpClientBuilder
Type Parameters
- TClient
The type of the typed client. They type specified will be registered in the service collection as a transient service.
Parameters
- builder
- IHttpClientBuilder
The IHttpClientBuilder.
- factory
- Func<HttpClient,TClient>
A factory function that will be used to construct the typed client.
Returns
Remarks
TClient
instances constructed with the appropriate HttpClient can be retrieved from GetService(Type) (and related methods) by providing TClient
as the service type.
Calling AddTypedClient<TClient>(IHttpClientBuilder, Func<HttpClient,TClient>) will register a typed client binding that creates TClient
using the provided factory function.