HttpClientBuilderExtensions.AddTypedClient 方法

定义

重载

AddTypedClient<TClient,TImplementation>(IHttpClientBuilder)

配置 TClient 类型与已命名的 HttpClient(与 IHttpClientBuilder 关联)之间的绑定。 创建的实例的类型为 TImplementation

AddTypedClient<TClient>(IHttpClientBuilder)

配置 TClient 类型与已命名的 HttpClient(与 IHttpClientBuilder 关联)之间的绑定。

AddTypedClient<TClient>(IHttpClientBuilder, Func<HttpClient,IServiceProvider,TClient>)

配置 TClient 类型与已命名的 HttpClient(与 IHttpClientBuilder 关联)之间的绑定。

AddTypedClient<TClient>(IHttpClientBuilder, Func<HttpClient,TClient>)

配置 TClient 类型与已命名的 HttpClient(与 IHttpClientBuilder 关联)之间的绑定。

AddTypedClient<TClient,TImplementation>(IHttpClientBuilder)

Source:
HttpClientBuilderExtensions.cs
Source:
HttpClientBuilderExtensions.cs
Source:
HttpClientBuilderExtensions.cs
Source:
HttpClientBuilderExtensions.cs

配置 TClient 类型与已命名的 HttpClient(与 IHttpClientBuilder 关联)之间的绑定。 创建的实例的类型为 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

类型参数

TClient

类型化客户端的声明类型。 指定的类型将在服务集合中注册为暂时性服务。 有关创作类型化客户端的更多详细信息,请参阅 ITypedHttpClientFactory<TClient>

TImplementation

类型化客户端的实现类型。 指定的类型将由 实例化 ITypedHttpClientFactory<TClient>

参数

返回

注解

TClient使用适当的构造的实例 HttpClient 可以 GetService(Type) 通过 TClient 作为服务类型提供,从(和相关方法)中进行检索。

调用 AddTypedClient<TClient,TImplementation>(IHttpClientBuilder) 将注册使用 ITypedHttpClientFactory<TClient>创建的TImplementation类型化客户端绑定。

类型化客户端的服务依赖项将从用于解析类型化客户端的同一服务提供程序解析。 无法从绑定到消息处理程序(独立管理)的范围访问服务。

适用于

AddTypedClient<TClient>(IHttpClientBuilder)

Source:
HttpClientBuilderExtensions.cs
Source:
HttpClientBuilderExtensions.cs
Source:
HttpClientBuilderExtensions.cs
Source:
HttpClientBuilderExtensions.cs

配置 TClient 类型与已命名的 HttpClient(与 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

类型参数

TClient

类型化客户端的类型。 指定的类型将在服务集合中注册为暂时性服务。 有关创作类型化客户端的更多详细信息,请参阅 ITypedHttpClientFactory<TClient>

参数

返回

注解

TClient使用适当的构造的实例 HttpClient 可以 GetService(Type) 通过 TClient 作为服务类型提供,从(和相关方法)中进行检索。

调用 AddTypedClient<TClient>(IHttpClientBuilder) 将注册使用 ITypedHttpClientFactory<TClient>创建的TClient类型化客户端绑定。

类型化客户端的服务依赖项将从用于解析类型化客户端的同一服务提供程序解析。 无法从绑定到消息处理程序(独立管理)的范围访问服务。

适用于

AddTypedClient<TClient>(IHttpClientBuilder, Func<HttpClient,IServiceProvider,TClient>)

Source:
HttpClientBuilderExtensions.cs
Source:
HttpClientBuilderExtensions.cs
Source:
HttpClientBuilderExtensions.cs
Source:
HttpClientBuilderExtensions.cs

配置 TClient 类型与已命名的 HttpClient(与 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

类型参数

TClient

类型化客户端的类型。 指定的类型将在服务集合中注册为暂时性服务。

参数

factory
Func<HttpClient,IServiceProvider,TClient>

将用于构造类型化客户端的工厂函数。

返回

注解

TClient使用适当的构造的实例 HttpClient 可以 GetService(Type) 通过 TClient 作为服务类型提供,从(和相关方法)中进行检索。

调用 AddTypedClient<TClient>(IHttpClientBuilder, Func<HttpClient,IServiceProvider,TClient>) 将注册使用提供的工厂函数创建的 TClient 类型化客户端绑定。

适用于

AddTypedClient<TClient>(IHttpClientBuilder, Func<HttpClient,TClient>)

Source:
HttpClientBuilderExtensions.cs
Source:
HttpClientBuilderExtensions.cs
Source:
HttpClientBuilderExtensions.cs
Source:
HttpClientBuilderExtensions.cs

配置 TClient 类型与已命名的 HttpClient(与 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

类型参数

TClient

类型化客户端的类型。 指定的类型将在服务集合中注册为暂时性服务。

参数

factory
Func<HttpClient,TClient>

将用于构造类型化客户端的工厂函数。

返回

注解

TClient使用适当的构造的实例 HttpClient 可以 GetService(Type) 通过 TClient 作为服务类型提供,从(和相关方法)中进行检索。

调用 AddTypedClient<TClient>(IHttpClientBuilder, Func<HttpClient,TClient>) 将注册使用提供的工厂函数创建的 TClient 类型化客户端绑定。

适用于