IServiceCollection 介面

定義

指定服務描述項集合的合約。

public interface class IServiceCollection : System::Collections::Generic::ICollection<Microsoft::Extensions::DependencyInjection::ServiceDescriptor ^>, System::Collections::Generic::IEnumerable<Microsoft::Extensions::DependencyInjection::ServiceDescriptor ^>, System::Collections::Generic::IList<Microsoft::Extensions::DependencyInjection::ServiceDescriptor ^>
public interface IServiceCollection : System.Collections.Generic.ICollection<Microsoft.Extensions.DependencyInjection.ServiceDescriptor>, System.Collections.Generic.IEnumerable<Microsoft.Extensions.DependencyInjection.ServiceDescriptor>, System.Collections.Generic.IList<Microsoft.Extensions.DependencyInjection.ServiceDescriptor>
type IServiceCollection = interface
    interface IList<ServiceDescriptor>
    interface ICollection<ServiceDescriptor>
    interface seq<ServiceDescriptor>
    interface IEnumerable
type IServiceCollection = interface
    interface ICollection<ServiceDescriptor>
    interface seq<ServiceDescriptor>
    interface IEnumerable
    interface IList<ServiceDescriptor>
Public Interface IServiceCollection
Implements ICollection(Of ServiceDescriptor), IEnumerable(Of ServiceDescriptor), IList(Of ServiceDescriptor)
衍生
實作

屬性

Count

取得 ICollection<T> 中所包含的項目數。

(繼承來源 ICollection<T>)
IsReadOnly

取得值,指出 ICollection<T> 是否唯讀。

(繼承來源 ICollection<T>)
Item[Int32]

在指定的索引位置上取得或設定項目。

(繼承來源 IList<T>)

方法

Add(T)

將項目加入至 ICollection<T>

(繼承來源 ICollection<T>)
Clear()

ICollection<T> 中移除所有項目。

(繼承來源 ICollection<T>)
Contains(T)

判斷 ICollection<T> 是否包含特定值。

(繼承來源 ICollection<T>)
CopyTo(T[], Int32)

從特定的 ICollection<T> 索引開始,將 Array 的項目複製到 Array

(繼承來源 ICollection<T>)
GetEnumerator()

傳回逐一查看集合的列舉值。

(繼承來源 IEnumerable)
IndexOf(T)

判斷 IList<T> 中指定項目的索引。

(繼承來源 IList<T>)
Insert(Int32, T)

將項目插入位於指定索引的 IList<T>

(繼承來源 IList<T>)
Remove(T)

ICollection<T> 移除特定物件之第一個符合的元素。

(繼承來源 ICollection<T>)
RemoveAt(Int32)

移除在指定索引處的 IList<T> 項目。

(繼承來源 IList<T>)

擴充方法

AddWebEncoders(IServiceCollection)

HtmlEncoderJavaScriptEncoderUrlEncoder 新增至指定的 services

AddWebEncoders(IServiceCollection, Action<WebEncoderOptions>)

HtmlEncoderJavaScriptEncoderUrlEncoder 新增至指定的 services

Add(IServiceCollection, ServiceDescriptor)

將指定的 descriptor 加入至 collection

Add(IServiceCollection, IEnumerable<ServiceDescriptor>)

ServiceDescriptor 的序列新增至 collection

RemoveAll(IServiceCollection, Type)

移除 IServiceCollectionserviceType 類型的所有服務。

RemoveAll<T>(IServiceCollection)

移除 IServiceCollectionT 類型的所有服務。

Replace(IServiceCollection, ServiceDescriptor)

移除 IServiceCollection 中具有與 descriptor 相同服務類型的第一個服務,並將 descriptor 新增至集合。

TryAdd(IServiceCollection, ServiceDescriptor)

如果尚未註冊服務類型,則將指定的 descriptor 新增至 collection

TryAdd(IServiceCollection, IEnumerable<ServiceDescriptor>)

如果尚未註冊服務類型,則將指定的 descriptors 新增至 collection

TryAddEnumerable(IServiceCollection, ServiceDescriptor)

如果現有描述項具有相同的 ServiceType,以及尚未存在於 services 中的實作,則新增 ServiceDescriptor

TryAddEnumerable(IServiceCollection, IEnumerable<ServiceDescriptor>)

如果現有描述項具有相同的 ServiceType,以及尚未存在於 services 中的實作,則新增特定的 ServiceDescriptor

TryAddScoped(IServiceCollection, Type)

如果尚未註冊服務類型,則將指定的 service 作為 Scoped 服務新增至 collection

TryAddScoped(IServiceCollection, Type, Func<IServiceProvider,Object>)

如果尚未註冊服務類型,則使用 implementationFactory 中指定的 Factory,將指定的 service 作為 Scoped 服務新增至 collection

TryAddScoped(IServiceCollection, Type, Type)

如果尚未註冊服務類型,則將所指定 service 作為具有 implementationTypeScoped 服務新增至 collection

TryAddScoped<TService>(IServiceCollection)

如果尚未註冊服務類型,則將指定的 TService 作為 Scoped 服務新增至 collection

TryAddScoped<TService>(IServiceCollection, Func<IServiceProvider,TService>)

如果尚未註冊服務類型,則使用 implementationFactory 中指定的 Factory,將指定的 TService 作為 Scoped 服務新增至 services

TryAddScoped<TService,TImplementation>(IServiceCollection)

如果尚未註冊服務類型,則將指定 TService 作為 TImplementation 中指定的 Scoped 服務實作類型新增至 collection

TryAddSingleton(IServiceCollection, Type)

如果尚未註冊服務類型,則將指定的 service 作為 Singleton 服務新增至 collection

TryAddSingleton(IServiceCollection, Type, Func<IServiceProvider,Object>)

如果尚未註冊服務類型,則使用 implementationFactory 中指定的 Factory,將指定的 service 作為 Singleton 服務新增至 collection

TryAddSingleton(IServiceCollection, Type, Type)

如果尚未註冊服務類型,則將所指定 service 作為具有 implementationTypeSingleton 服務新增至 collection

TryAddSingleton<TService>(IServiceCollection)

如果尚未註冊服務類型,則將指定的 TService 作為 Singleton 服務新增至 collection

TryAddSingleton<TService>(IServiceCollection, TService)

如果尚未註冊服務類型,則使用 instance 中指定的執行個體,將指定的 TService 作為 Singleton 服務新增至 collection

TryAddSingleton<TService>(IServiceCollection, Func<IServiceProvider,TService>)

如果尚未註冊服務類型,則使用 implementationFactory 中指定的 Factory,將指定的 TService 作為 Singleton 服務新增至 services

TryAddSingleton<TService,TImplementation>(IServiceCollection)

如果尚未註冊服務類型,則將指定 TService 作為 TImplementation 中指定的 Singleton 服務實作類型新增至 collection

TryAddTransient(IServiceCollection, Type)

如果尚未註冊服務類型,則將指定的 service 作為 Transient 服務新增至 collection

TryAddTransient(IServiceCollection, Type, Func<IServiceProvider,Object>)

如果尚未註冊服務類型,則使用 implementationFactory 中指定的 Factory,將指定的 service 作為 Transient 服務新增至 collection

TryAddTransient(IServiceCollection, Type, Type)

如果尚未註冊服務類型,則將所指定 service 作為具有 implementationTypeTransient 服務新增至 collection

TryAddTransient<TService>(IServiceCollection)

如果尚未註冊服務類型,則將指定的 TService 作為 Transient 服務新增至 collection

TryAddTransient<TService>(IServiceCollection, Func<IServiceProvider,TService>)

如果尚未註冊服務類型,則使用 implementationFactory 中指定的 Factory,將指定的 TService 作為 Transient 服務新增至 services

TryAddTransient<TService,TImplementation>(IServiceCollection)

如果尚未註冊服務類型,則將指定 TService 作為 TImplementation 中指定的 Transient 服務實作類型新增至 collection

AddHealthChecks(IServiceCollection)

使用提供的委派來註冊健康狀態檢查,以將 HealthCheckService 新增至容器。

AddHttpClient(IServiceCollection)

IHttpClientFactory 和相關服務新增至 IServiceCollection

AddHttpClient(IServiceCollection, String)

IHttpClientFactory 和相關服務新增至 IServiceCollection,並設定具名 HttpClient

AddHttpClient(IServiceCollection, String, Action<IServiceProvider,HttpClient>)

IHttpClientFactory 和相關服務新增至 IServiceCollection,並設定具名 HttpClient

AddHttpClient(IServiceCollection, String, Action<HttpClient>)

IHttpClientFactory 和相關服務新增至 IServiceCollection,並設定具名 HttpClient

AddHttpClient<TClient>(IServiceCollection)

IHttpClientFactory 和相關服務新增至 IServiceCollection,並設定 TClient 類型與具名 HttpClient 之間的繫結。 用戶端名稱將會設定為 TClient 的完整名稱。

AddHttpClient<TClient>(IServiceCollection, Action<IServiceProvider,HttpClient>)

IHttpClientFactory 和相關服務新增至 IServiceCollection,並設定 TClient 類型與具名 HttpClient 之間的繫結。 用戶端名稱將會設定為 TClient 的類型名稱。

AddHttpClient<TClient>(IServiceCollection, Action<HttpClient>)

IHttpClientFactory 和相關服務新增至 IServiceCollection,並設定 TClient 類型與具名 HttpClient 之間的繫結。 用戶端名稱將會設定為 TClient 的類型名稱。

AddHttpClient<TClient>(IServiceCollection, String)

IHttpClientFactory 和相關服務新增至 IServiceCollection,並設定 TClient 類型與具名 HttpClient 之間的繫結。

AddHttpClient<TClient>(IServiceCollection, String, Action<IServiceProvider,HttpClient>)

IHttpClientFactory 和相關服務新增至 IServiceCollection,並設定 TClient 類型與具名 HttpClient 之間的繫結。

AddHttpClient<TClient>(IServiceCollection, String, Action<HttpClient>)

IHttpClientFactory 和相關服務新增至 IServiceCollection,並設定 TClient 類型與具名 HttpClient 之間的繫結。

AddHttpClient<TClient,TImplementation>(IServiceCollection)

IHttpClientFactory 和相關服務新增至 IServiceCollection,並設定 TClient 類型與具名 HttpClient 之間的繫結。 用戶端名稱將會設定為 TClient 的類型名稱。

AddHttpClient<TClient,TImplementation>(IServiceCollection, Action<IServiceProvider,HttpClient>)

IHttpClientFactory 和相關服務新增至 IServiceCollection,並設定 TClient 類型與具名 HttpClient 之間的繫結。 用戶端名稱將會設定為 TClient 的類型名稱。

AddHttpClient<TClient,TImplementation>(IServiceCollection, Action<HttpClient>)

IHttpClientFactory 和相關服務新增至 IServiceCollection,並設定 TClient 類型與具名 HttpClient 之間的繫結。 用戶端名稱將會設定為 TClient 的類型名稱。

AddHttpClient<TClient,TImplementation>(IServiceCollection, Func<HttpClient,TImplementation>)

IHttpClientFactory 和相關服務新增至 IServiceCollection,並設定 TClient 類型與具名 HttpClient 之間的繫結。

AddHttpClient<TClient,TImplementation>(IServiceCollection, Func<HttpClient,IServiceProvider,TImplementation>)

IHttpClientFactory 和相關服務新增至 IServiceCollection,並設定 TClient 類型與具名 HttpClient 之間的繫結。

AddHttpClient<TClient,TImplementation>(IServiceCollection, String)

IHttpClientFactory 和相關服務新增至 IServiceCollection,並設定 TClient 類型與具名 HttpClient 之間的繫結。 用戶端名稱將會設定為 TClient 的類型名稱。

AddHttpClient<TClient,TImplementation>(IServiceCollection, String, Action<IServiceProvider,HttpClient>)

IHttpClientFactory 和相關服務新增至 IServiceCollection,並設定 TClient 類型與具名 HttpClient 之間的繫結。

AddHttpClient<TClient,TImplementation>(IServiceCollection, String, Action<HttpClient>)

IHttpClientFactory 和相關服務新增至 IServiceCollection,並設定 TClient 類型與具名 HttpClient 之間的繫結。

AddHttpClient<TClient,TImplementation>(IServiceCollection, String, Func<HttpClient,TImplementation>)

IHttpClientFactory 和相關服務新增至 IServiceCollection,並設定 TClient 類型與具名 HttpClient 之間的繫結。

AddHttpClient<TClient,TImplementation>(IServiceCollection, String, Func<HttpClient,IServiceProvider,TImplementation>)

IHttpClientFactory 和相關服務新增至 IServiceCollection,並設定 TClient 類型與具名 HttpClient 之間的繫結。

AddLocalization(IServiceCollection)

新增應用程式當地語系化所需的服務。

AddLocalization(IServiceCollection, Action<LocalizationOptions>)

新增應用程式當地語系化所需的服務。

AddLogging(IServiceCollection)

將記錄服務新增至指定的 IServiceCollection

AddLogging(IServiceCollection, Action<ILoggingBuilder>)

將記錄服務新增至指定的 IServiceCollection

AddDistributedMemoryCache(IServiceCollection)

新增 IDistributedCache 的預設實作,將記憶體中的項目儲存至 IServiceCollection。 需要分散式快取才能運作的架構,可以安全地將此相依性新增為其相依性清單的一部分,以確保至少有一個可用的實作。

AddDistributedMemoryCache(IServiceCollection, Action<MemoryDistributedCacheOptions>)

新增 IDistributedCache 的預設實作,將記憶體中的項目儲存至 IServiceCollection。 需要分散式快取才能運作的架構,可以安全地將此相依性新增為其相依性清單的一部分,以確保至少有一個可用的實作。

AddMemoryCache(IServiceCollection)

IMemoryCache 的非分散式記憶體內實作新增至 IServiceCollection

AddMemoryCache(IServiceCollection, Action<MemoryCacheOptions>)

IMemoryCache 的非分散式記憶體內實作新增至 IServiceCollection

Configure<TOptions>(IServiceCollection, IConfiguration)

註冊 TOptions 將要繫結的組態執行個體,並在組態變更時更新選項。

Configure<TOptions>(IServiceCollection, IConfiguration, Action<BinderOptions>)

註冊 TOptions 將繫結的組態執行個體。

Configure<TOptions>(IServiceCollection, String, IConfiguration)

註冊 TOptions 將繫結的組態執行個體。

Configure<TOptions>(IServiceCollection, String, IConfiguration, Action<BinderOptions>)

註冊 TOptions 將繫結的組態執行個體。

AddOptions(IServiceCollection)

新增使用選項所需的服務。

AddOptions<TOptions>(IServiceCollection)

取得選項產生器,這個產生器會將 Configure 相同具名 TOptions 的呼叫轉送至基礎服務集合。

AddOptions<TOptions>(IServiceCollection, String)

取得選項產生器,這個產生器會將 Configure 相同具名 TOptions 的呼叫轉送至基礎服務集合。

Configure<TOptions>(IServiceCollection, Action<TOptions>)

註冊用來在啟動期間一次設定特定選項類型的動作。 這會在 PostConfigure<TOptions>(IServiceCollection, Action<TOptions>) 之前執行。 對設定進行更新不會再次叫用動作。

Configure<TOptions>(IServiceCollection, String, Action<TOptions>)

註冊用來設定特定選項類型的動作。 這些會在 PostConfigure<TOptions>(IServiceCollection, Action<TOptions>) 之前執行。

ConfigureAll<TOptions>(IServiceCollection, Action<TOptions>)

註冊用於設定特定選項類型的所有執行個體動作。

ConfigureOptions(IServiceCollection, Object)

註冊將擁有其 I[Post]ConfigureOptions 所有已註冊的物件。

ConfigureOptions(IServiceCollection, Type)

註冊類型,此類型會擁有其 I[Post]ConfigureOptions 所有已註冊的 。

ConfigureOptions<TConfigureOptions>(IServiceCollection)

註冊類型,此類型會擁有其 I[Post]ConfigureOptions 所有已註冊的 。

PostConfigure<TOptions>(IServiceCollection, Action<TOptions>)

註冊用於初始化特定類型選項的動作。 這些會在 Configure<TOptions>(IServiceCollection, Action<TOptions>) 之後執行。

PostConfigure<TOptions>(IServiceCollection, String, Action<TOptions>)

註冊用來設定特定選項類型的動作。 這些會在 Configure<TOptions>(IServiceCollection, Action<TOptions>) 之後執行。

PostConfigureAll<TOptions>(IServiceCollection, Action<TOptions>)

註冊用於張貼設定特定選項類型的所有執行個體動作。 這些會在 Configure<TOptions>(IServiceCollection, Action<TOptions>) 之後執行。

AddPolicyRegistry(IServiceCollection)

使用服務類型 IPolicyRegistry<TKey>IReadOnlyPolicyRegistry<TKey> 在服務集合中註冊空白 PolicyRegistry,並傳回新建立的登錄。

AddPolicyRegistry(IServiceCollection, IPolicyRegistry<String>)

使用服務類型 IPolicyRegistry<TKey>IReadOnlyPolicyRegistry<TKey> 在服務集合中註冊所提供的 IPolicyRegistry<TKey>,並傳回所提供的登錄。

AddDistributedRedisCache(IServiceCollection, Action<RedisCacheOptions>)

將 Redis 分散式快取服務新增至指定的 IServiceCollection

BuildServiceProvider(IServiceCollection)

從所提供 IServiceCollection 建立包含服務的 ServiceProvider

BuildServiceProvider(IServiceCollection, ServiceProviderOptions)

從所提供 IServiceCollection 建立包含服務的 ServiceProvider,選擇性地啟用服務建立和範圍驗證。

BuildServiceProvider(IServiceCollection, Boolean)

從所提供 IServiceCollection 建立包含服務的 ServiceProvider,選擇性地啟用範圍驗證。

AddHostedService<THostedService>(IServiceCollection)

為指定的類型新增 IHostedService 註冊。

AddHostedService<THostedService>(IServiceCollection, Func<IServiceProvider,THostedService>)

為指定的類型新增 IHostedService 註冊。

AddScoped(IServiceCollection, Type)

serviceType 中指定類型的範圍服務,新增至指定的 IServiceCollection

AddScoped(IServiceCollection, Type, Func<IServiceProvider,Object>)

serviceType 中指定類型的範圍服務,以及 implementationFactory 中指定的 Factory,新增至指定的 IServiceCollection

AddScoped(IServiceCollection, Type, Type)

serviceType 中指定類型的範圍服務,以及在 implementationType 中指定類型的實作,新增至指定的 IServiceCollection

AddScoped<TService>(IServiceCollection)

TService 中指定類型的範圍服務,新增至指定的 IServiceCollection

AddScoped<TService>(IServiceCollection, Func<IServiceProvider,TService>)

TService 中指定類型的範圍服務,以及 implementationFactory 中指定的 Factory,新增至指定的 IServiceCollection

AddScoped<TService,TImplementation>(IServiceCollection)

TService 中指定類型的範圍服務,以及在 TImplementation 中指定的實作類型,新增至指定的 IServiceCollection

AddScoped<TService,TImplementation>(IServiceCollection, Func<IServiceProvider,TImplementation>)

使用 implementationFactory 中指定的 Factory,將 TService 中指定類型的範圍服務,以及 TImplementation 中指定的實作類型,新增至指定的 IServiceCollection

AddSingleton(IServiceCollection, Type)

serviceType 中指定類型的單一服務,新增至指定的 IServiceCollection

AddSingleton(IServiceCollection, Type, Func<IServiceProvider,Object>)

serviceType 中指定類型的單一服務,以及 implementationFactory 中指定的 Factory,新增至指定的 IServiceCollection

AddSingleton(IServiceCollection, Type, Object)

serviceType 中指定類型的單一服務,以及 implementationInstance 中指定的執行個體,新增至指定的 IServiceCollection

AddSingleton(IServiceCollection, Type, Type)

serviceType 中指定類型的單一服務,以及在 implementationType 中指定類型的實作,新增至指定的 IServiceCollection

AddSingleton<TService>(IServiceCollection)

TService 中指定類型的單一服務,新增至指定的 IServiceCollection

AddSingleton<TService>(IServiceCollection, TService)

TService 中指定類型的單一服務,以及 implementationInstance 中指定的執行個體,新增至指定的 IServiceCollection

AddSingleton<TService>(IServiceCollection, Func<IServiceProvider,TService>)

TService 中指定類型的單一服務,以及 implementationFactory 中指定的 Factory,新增至指定的 IServiceCollection

AddSingleton<TService,TImplementation>(IServiceCollection)

TService 中指定類型的單一服務,以及在 TImplementation 中指定的實作類型,新增至指定的 IServiceCollection

AddSingleton<TService,TImplementation>(IServiceCollection, Func<IServiceProvider,TImplementation>)

使用 implementationFactory 中指定的 Factory,將 TService 中指定類型的單一服務,以及 TImplementation 中指定的實作類型,新增至指定的 IServiceCollection

AddTransient(IServiceCollection, Type)

serviceType 中指定類型的暫時性服務,新增至指定的 IServiceCollection

AddTransient(IServiceCollection, Type, Func<IServiceProvider,Object>)

serviceType 中指定類型的暫時性服務,以及 implementationFactory 中指定的 Factory,新增至指定的 IServiceCollection

AddTransient(IServiceCollection, Type, Type)

serviceType 中指定類型的暫時性服務,以及在 implementationType 中指定類型的實作,新增至指定的 IServiceCollection

AddTransient<TService>(IServiceCollection)

TService 中指定類型的暫時性服務,新增至指定的 IServiceCollection

AddTransient<TService>(IServiceCollection, Func<IServiceProvider,TService>)

TService 中指定類型的暫時性服務,以及 implementationFactory 中指定的 Factory,新增至指定的 IServiceCollection

AddTransient<TService,TImplementation>(IServiceCollection)

TService 中指定類型的暫時性服務,以及在 TImplementation 中指定的實作類型,新增至指定的 IServiceCollection

AddTransient<TService,TImplementation>(IServiceCollection, Func<IServiceProvider,TImplementation>)

使用 implementationFactory 中指定的 Factory,將 TService 中指定類型的暫時性服務,以及 TImplementation 中指定的實作類型,新增至指定的 IServiceCollection

AddDistributedSqlServerCache(IServiceCollection, Action<SqlServerCacheOptions>)

將 Microsoft SQL Server 分散式快取服務新增至指定的 IServiceCollection

AddStackExchangeRedisCache(IServiceCollection, Action<RedisCacheOptions>)

將 Redis 分散式快取服務新增至指定的 IServiceCollection

AsReadOnly<T>(IList<T>)

傳回指定清單的唯讀 ReadOnlyCollection<T> 包裝函式。

CopyToDataTable<T>(IEnumerable<T>)

根據輸入 DataTable 物件 (其中泛型參數 TDataRow) 傳回包含 IEnumerable<T> 物件複本的 DataRow

CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption)

根據輸入 DataRow 物件 (其中泛型參數 TDataTable),將 IEnumerable<T> 物件複製到指定的 DataRow

CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption, FillErrorEventHandler)

根據輸入 DataRow 物件 (其中泛型參數 TDataTable),將 IEnumerable<T> 物件複製到指定的 DataRow

適用於