共用方式為


HttpClientBuilderExtensions.AddTypedClient 方法

定義

多載

AddTypedClient<TClient,TImplementation>(IHttpClientBuilder)

設定 TClient 類型和與 IHttpClientBuilder 建立關聯之具名 HttpClient 之間的繫結。 建立的執行個體將屬於類型 TImplementation

AddTypedClient<TClient>(IHttpClientBuilder)

設定 TClient 類型和與 IHttpClientBuilder 建立關聯之具名 HttpClient 之間的繫結。

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

設定 TClient 類型和與 IHttpClientBuilder 建立關聯之具名 HttpClient 之間的繫結。

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

設定 TClient 類型和與 IHttpClientBuilder 建立關聯之具名 HttpClient 之間的繫結。

AddTypedClient<TClient,TImplementation>(IHttpClientBuilder)

來源:
HttpClientBuilderExtensions.cs
來源:
HttpClientBuilderExtensions.cs
來源:
HttpClientBuilderExtensions.cs
來源:
HttpClientBuilderExtensions.cs

設定 TClient 類型和與 IHttpClientBuilder 建立關聯之具名 HttpClient 之間的繫結。 建立的執行個體將屬於類型 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)

來源:
HttpClientBuilderExtensions.cs
來源:
HttpClientBuilderExtensions.cs
來源:
HttpClientBuilderExtensions.cs
來源:
HttpClientBuilderExtensions.cs

設定 TClient 類型和與 IHttpClientBuilder 建立關聯之具名 HttpClient 之間的繫結。

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>)

來源:
HttpClientBuilderExtensions.cs
來源:
HttpClientBuilderExtensions.cs
來源:
HttpClientBuilderExtensions.cs
來源:
HttpClientBuilderExtensions.cs

設定 TClient 類型和與 IHttpClientBuilder 建立關聯之具名 HttpClient 之間的繫結。

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>

將用於建立具類型用戶端的 Factory 函式。

傳回

備註

TClient以適當方式所建立的實例, HttpClient 可以藉 GetService(Type) 由提供 TClient 做為服務類型,從(和相關的方法)中抓取。

呼叫 AddTypedClient<TClient>(IHttpClientBuilder, Func<HttpClient,IServiceProvider,TClient>) 會註冊使用提供的 Factory 函式所建立 TClient 的具型別客戶端系結。

適用於

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

來源:
HttpClientBuilderExtensions.cs
來源:
HttpClientBuilderExtensions.cs
來源:
HttpClientBuilderExtensions.cs
來源:
HttpClientBuilderExtensions.cs

設定 TClient 類型和與 IHttpClientBuilder 建立關聯之具名 HttpClient 之間的繫結。

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>

將用於建立具類型用戶端的 Factory 函式。

傳回

備註

TClient以適當方式所建立的實例, HttpClient 可以藉 GetService(Type) 由提供 TClient 做為服務類型,從(和相關的方法)中抓取。

呼叫 AddTypedClient<TClient>(IHttpClientBuilder, Func<HttpClient,TClient>) 會註冊使用提供的 Factory 函式所建立 TClient 的具型別客戶端系結。

適用於