ServiceCollection 類別
定義
IServiceCollection 的預設實作。Default implementation of IServiceCollection.
public ref class ServiceCollection : Microsoft::Extensions::DependencyInjection::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 class ServiceCollection : Microsoft.Extensions.DependencyInjection.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 ServiceCollection = class
interface IServiceCollection
interface IList<ServiceDescriptor>
interface ICollection<ServiceDescriptor>
interface seq<ServiceDescriptor>
interface IEnumerable
type ServiceCollection = class
interface IServiceCollection
interface ICollection<ServiceDescriptor>
interface seq<ServiceDescriptor>
interface IEnumerable
interface IList<ServiceDescriptor>
Public Class ServiceCollection
Implements ICollection(Of ServiceDescriptor), IEnumerable(Of ServiceDescriptor), IList(Of ServiceDescriptor), IServiceCollection
- 繼承
-
ServiceCollection
- 實作
建構函式
ServiceCollection() |
屬性
Count |
取得 ICollection<T> 中所包含的項目數。Gets the number of elements contained in the ICollection<T>. |
IsReadOnly |
取得值,指出 ICollection<T> 是否唯讀。Gets a value indicating whether the ICollection<T> is read-only. |
Item[Int32] |
在指定的索引位置上取得或設定項目。Gets or sets the element at the specified index. |
方法
Clear() |
從 ICollection<T> 中移除所有項目。Removes all items from the ICollection<T>. |
Contains(ServiceDescriptor) |
判斷 ICollection<T> 是否包含特定值。Determines whether the ICollection<T> contains a specific value. |
CopyTo(ServiceDescriptor[], Int32) |
從特定的 ICollection<T> 索引開始,將 Array 的項目複製到 Array。Copies the elements of the ICollection<T> to an Array, starting at a particular Array index. |
Equals(Object) |
判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object. (繼承來源 Object) |
GetEnumerator() |
傳回逐一查看集合的列舉值。Returns an enumerator that iterates through the collection. |
GetHashCode() |
做為預設雜湊函式。Serves as the default hash function. (繼承來源 Object) |
GetType() |
取得目前執行個體的 Type。Gets the Type of the current instance. (繼承來源 Object) |
IndexOf(ServiceDescriptor) |
判斷 IList<T> 中指定項目的索引。Determines the index of a specific item in the IList<T>. |
Insert(Int32, ServiceDescriptor) |
將項目插入位於指定索引的 IList<T>。Inserts an item to the IList<T> at the specified index. |
MemberwiseClone() |
建立目前 Object 的淺層複製。Creates a shallow copy of the current Object. (繼承來源 Object) |
Remove(ServiceDescriptor) |
從 ICollection<T> 移除特定物件之第一個符合的元素。Removes the first occurrence of a specific object from the ICollection<T>. |
RemoveAt(Int32) |
移除在指定索引處的 IList<T> 項目。Removes the IList<T> item at the specified index. |
ToString() |
傳回代表目前物件的字串。Returns a string that represents the current object. (繼承來源 Object) |
明確介面實作
ICollection<ServiceDescriptor>.Add(ServiceDescriptor) |
將項目加入至 ICollection<T>。Adds an item to the ICollection<T>. |
IEnumerable.GetEnumerator() |
傳回逐一查看集合的列舉值。Returns an enumerator that iterates through a collection. |
擴充方法
AddWebEncoders(IServiceCollection) |
將 HtmlEncoder、JavaScriptEncoder 和 UrlEncoder 新增至指定的 |
AddWebEncoders(IServiceCollection, Action<WebEncoderOptions>) |
將 HtmlEncoder、JavaScriptEncoder 和 UrlEncoder 新增至指定的 |
Add(IServiceCollection, ServiceDescriptor) |
將指定的 |
Add(IServiceCollection, IEnumerable<ServiceDescriptor>) |
將 ServiceDescriptor 的序列新增至 |
RemoveAll(IServiceCollection, Type) |
移除 IServiceCollection 中 |
RemoveAll<T>(IServiceCollection) |
移除 IServiceCollection 中 |
Replace(IServiceCollection, ServiceDescriptor) |
移除 IServiceCollection 中具有與 |
TryAdd(IServiceCollection, ServiceDescriptor) |
如果尚未註冊服務類型,則將指定的 |
TryAdd(IServiceCollection, IEnumerable<ServiceDescriptor>) |
如果尚未註冊服務類型,則將指定的 |
TryAddEnumerable(IServiceCollection, ServiceDescriptor) |
如果現有描述項具有相同的 ServiceType,以及尚未存在於 |
TryAddEnumerable(IServiceCollection, IEnumerable<ServiceDescriptor>) |
如果現有描述項具有相同的 ServiceType,以及尚未存在於 |
TryAddScoped(IServiceCollection, Type) |
如果尚未註冊服務類型,則將指定的 |
TryAddScoped(IServiceCollection, Type, Func<IServiceProvider,Object>) |
如果尚未註冊服務類型,則使用 |
TryAddScoped(IServiceCollection, Type, Type) |
如果尚未註冊服務類型,則將所指定 |
TryAddScoped<TService>(IServiceCollection) |
如果尚未註冊服務類型,則將指定的 |
TryAddScoped<TService>(IServiceCollection, Func<IServiceProvider,TService>) |
如果尚未註冊服務類型,則使用 |
TryAddScoped<TService,TImplementation>(IServiceCollection) |
如果尚未註冊服務類型,則將指定 |
TryAddSingleton(IServiceCollection, Type) |
如果尚未註冊服務類型,則將指定的 |
TryAddSingleton(IServiceCollection, Type, Func<IServiceProvider,Object>) |
如果尚未註冊服務類型,則使用 |
TryAddSingleton(IServiceCollection, Type, Type) |
如果尚未註冊服務類型,則將所指定 |
TryAddSingleton<TService>(IServiceCollection) |
如果尚未註冊服務類型,則將指定的 |
TryAddSingleton<TService>(IServiceCollection, TService) |
如果尚未註冊服務類型,則使用 |
TryAddSingleton<TService>(IServiceCollection, Func<IServiceProvider,TService>) |
如果尚未註冊服務類型,則使用 |
TryAddSingleton<TService,TImplementation>(IServiceCollection) |
如果尚未註冊服務類型,則將指定 |
TryAddTransient(IServiceCollection, Type) |
如果尚未註冊服務類型,則將指定的 |
TryAddTransient(IServiceCollection, Type, Func<IServiceProvider,Object>) |
如果尚未註冊服務類型,則使用 |
TryAddTransient(IServiceCollection, Type, Type) |
如果尚未註冊服務類型,則將所指定 |
TryAddTransient<TService>(IServiceCollection) |
如果尚未註冊服務類型,則將指定的 |
TryAddTransient<TService>(IServiceCollection, Func<IServiceProvider,TService>) |
如果尚未註冊服務類型,則使用 |
TryAddTransient<TService,TImplementation>(IServiceCollection) |
如果尚未註冊服務類型,則將指定 |
AddHealthChecks(IServiceCollection) |
使用提供的委派來註冊健康狀態檢查,以將 HealthCheckService 新增至容器。Adds the HealthCheckService to the container, using the provided delegate to register health checks. |
AddHttpClient(IServiceCollection) |
將 IHttpClientFactory 和相關服務新增至 IServiceCollection。Adds the IHttpClientFactory and related services to the IServiceCollection. |
AddHttpClient(IServiceCollection, String) |
將 IHttpClientFactory 和相關服務新增至 IServiceCollection,並設定具名 HttpClient。Adds the IHttpClientFactory and related services to the IServiceCollection and configures a named HttpClient. |
AddHttpClient(IServiceCollection, String, Action<IServiceProvider,HttpClient>) |
將 IHttpClientFactory 和相關服務新增至 IServiceCollection,並設定具名 HttpClient。Adds the IHttpClientFactory and related services to the IServiceCollection and configures a named HttpClient. |
AddHttpClient(IServiceCollection, String, Action<HttpClient>) |
將 IHttpClientFactory 和相關服務新增至 IServiceCollection,並設定具名 HttpClient。Adds the IHttpClientFactory and related services to the IServiceCollection and configures a named HttpClient. |
AddHttpClient<TClient>(IServiceCollection) |
將 IHttpClientFactory 和相關服務新增至 IServiceCollection,並設定 |
AddHttpClient<TClient>(IServiceCollection, Action<IServiceProvider,HttpClient>) |
將 IHttpClientFactory 和相關服務新增至 IServiceCollection,並設定 |
AddHttpClient<TClient>(IServiceCollection, Action<HttpClient>) |
將 IHttpClientFactory 和相關服務新增至 IServiceCollection,並設定 |
AddHttpClient<TClient>(IServiceCollection, String) |
將 IHttpClientFactory 和相關服務新增至 IServiceCollection,並設定 |
AddHttpClient<TClient>(IServiceCollection, String, Action<IServiceProvider,HttpClient>) |
將 IHttpClientFactory 和相關服務新增至 IServiceCollection,並設定 |
AddHttpClient<TClient>(IServiceCollection, String, Action<HttpClient>) |
將 IHttpClientFactory 和相關服務新增至 IServiceCollection,並設定 |
AddHttpClient<TClient,TImplementation>(IServiceCollection) |
將 IHttpClientFactory 和相關服務新增至 IServiceCollection,並設定 |
AddHttpClient<TClient,TImplementation>(IServiceCollection, Action<IServiceProvider,HttpClient>) |
將 IHttpClientFactory 和相關服務新增至 IServiceCollection,並設定 |
AddHttpClient<TClient,TImplementation>(IServiceCollection, Action<HttpClient>) |
將 IHttpClientFactory 和相關服務新增至 IServiceCollection,並設定 |
AddHttpClient<TClient,TImplementation>(IServiceCollection, Func<HttpClient,TImplementation>) |
將 IHttpClientFactory 和相關服務新增至 IServiceCollection,並設定 |
AddHttpClient<TClient,TImplementation>(IServiceCollection, Func<HttpClient,IServiceProvider,TImplementation>) |
將 IHttpClientFactory 和相關服務新增至 IServiceCollection,並設定 |
AddHttpClient<TClient,TImplementation>(IServiceCollection, String) |
將 IHttpClientFactory 和相關服務新增至 IServiceCollection,並設定 |
AddHttpClient<TClient,TImplementation>(IServiceCollection, String, Action<IServiceProvider,HttpClient>) |
將 IHttpClientFactory 和相關服務新增至 IServiceCollection,並設定 |
AddHttpClient<TClient,TImplementation>(IServiceCollection, String, Action<HttpClient>) |
將 IHttpClientFactory 和相關服務新增至 IServiceCollection,並設定 |
AddHttpClient<TClient,TImplementation>(IServiceCollection, String, Func<HttpClient,TImplementation>) |
將 IHttpClientFactory 和相關服務新增至 IServiceCollection,並設定 |
AddHttpClient<TClient,TImplementation>(IServiceCollection, String, Func<HttpClient,IServiceProvider,TImplementation>) |
將 IHttpClientFactory 和相關服務新增至 IServiceCollection,並設定 |
AddLocalization(IServiceCollection) |
新增應用程式當地語系化所需的服務。Adds services required for application localization. |
AddLocalization(IServiceCollection, Action<LocalizationOptions>) |
新增應用程式當地語系化所需的服務。Adds services required for application localization. |
AddLogging(IServiceCollection) |
將記錄服務新增至指定的 IServiceCollection。Adds logging services to the specified IServiceCollection. |
AddLogging(IServiceCollection, Action<ILoggingBuilder>) |
將記錄服務新增至指定的 IServiceCollection。Adds logging services to the specified IServiceCollection. |
AddDistributedMemoryCache(IServiceCollection) |
新增 IDistributedCache 的預設實作,將記憶體中的項目儲存至 IServiceCollection。Adds a default implementation of IDistributedCache that stores items in memory to the IServiceCollection. 需要分散式快取才能運作的架構,可以安全地將此相依性新增為其相依性清單的一部分,以確保至少有一個可用的實作。Frameworks that require a distributed cache to work can safely add this dependency as part of their dependency list to ensure that there is at least one implementation available. |
AddDistributedMemoryCache(IServiceCollection, Action<MemoryDistributedCacheOptions>) |
新增 IDistributedCache 的預設實作,將記憶體中的項目儲存至 IServiceCollection。Adds a default implementation of IDistributedCache that stores items in memory to the IServiceCollection. 需要分散式快取才能運作的架構,可以安全地將此相依性新增為其相依性清單的一部分,以確保至少有一個可用的實作。Frameworks that require a distributed cache to work can safely add this dependency as part of their dependency list to ensure that there is at least one implementation available. |
AddMemoryCache(IServiceCollection) |
將 IMemoryCache 的非分散式記憶體內實作新增至 IServiceCollection。Adds a non distributed in memory implementation of IMemoryCache to the IServiceCollection. |
AddMemoryCache(IServiceCollection, Action<MemoryCacheOptions>) |
將 IMemoryCache 的非分散式記憶體內實作新增至 IServiceCollection。Adds a non distributed in memory implementation of IMemoryCache to the IServiceCollection. |
Configure<TOptions>(IServiceCollection, IConfiguration) |
註冊 |
Configure<TOptions>(IServiceCollection, IConfiguration, Action<BinderOptions>) |
註冊 TOptions 將繫結的組態執行個體。Registers a configuration instance which TOptions will bind against. |
Configure<TOptions>(IServiceCollection, String, IConfiguration) |
註冊 TOptions 將繫結的組態執行個體。Registers a configuration instance which TOptions will bind against. |
Configure<TOptions>(IServiceCollection, String, IConfiguration, Action<BinderOptions>) |
註冊 TOptions 將繫結的組態執行個體。Registers a configuration instance which TOptions will bind against. |
AddOptions(IServiceCollection) |
新增使用選項所需的服務。Adds services required for using options. |
AddOptions<TOptions>(IServiceCollection) |
取得選項產生器,將同樣名為 |
AddOptions<TOptions>(IServiceCollection, String) |
取得選項產生器,將同樣名為 |
Configure<TOptions>(IServiceCollection, Action<TOptions>) |
註冊用來在啟動期間一次設定特定選項類型的動作。Registers an action used to configure a particular type of options once during startup. 這會在 PostConfigure<TOptions>(IServiceCollection, Action<TOptions>) 之前執行。This is run before PostConfigure<TOptions>(IServiceCollection, Action<TOptions>). 對設定進行更新不會再次叫用動作。Updates to the configuration does not invoke the action again. |
Configure<TOptions>(IServiceCollection, String, Action<TOptions>) |
註冊用來設定特定選項類型的動作。Registers an action used to configure a particular type of options. 這些會在 PostConfigure<TOptions>(IServiceCollection, Action<TOptions>) 之前執行。These are run before PostConfigure<TOptions>(IServiceCollection, Action<TOptions>). |
ConfigureAll<TOptions>(IServiceCollection, Action<TOptions>) |
註冊用於設定特定選項類型的所有執行個體動作。Registers an action used to configure all instances of a particular type of options. |
ConfigureOptions(IServiceCollection, Object) |
註冊會將其所有 |
ConfigureOptions(IServiceCollection, Type) |
註冊會將其所有 |
ConfigureOptions<TConfigureOptions>(IServiceCollection) |
註冊會將其所有 |
PostConfigure<TOptions>(IServiceCollection, Action<TOptions>) |
註冊用於初始化特定類型選項的動作。Registers an action used to initialize a particular type of options. 這些會在 Configure<TOptions>(IServiceCollection, Action<TOptions>) 之後執行。These are run after Configure<TOptions>(IServiceCollection, Action<TOptions>). |
PostConfigure<TOptions>(IServiceCollection, String, Action<TOptions>) |
註冊用來設定特定選項類型的動作。Registers an action used to configure a particular type of options. 這些會在 Configure<TOptions>(IServiceCollection, Action<TOptions>) 之後執行。These are run after Configure<TOptions>(IServiceCollection, Action<TOptions>). |
PostConfigureAll<TOptions>(IServiceCollection, Action<TOptions>) |
註冊用於張貼設定特定選項類型的所有執行個體動作。Registers an action used to post configure all instances of a particular type of options. 這些會在 Configure<TOptions>(IServiceCollection, Action<TOptions>) 之後執行。These are run after Configure<TOptions>(IServiceCollection, Action<TOptions>). |
AddPolicyRegistry(IServiceCollection) |
使用服務類型 IPolicyRegistry<TKey> 和 IReadOnlyPolicyRegistry<TKey> 在服務集合中註冊空白 PolicyRegistry,並傳回新建立的登錄。Registers an empty PolicyRegistry in the service collection with service types IPolicyRegistry<TKey>, and IReadOnlyPolicyRegistry<TKey> and returns the newly created registry. |
AddPolicyRegistry(IServiceCollection, IPolicyRegistry<String>) |
使用服務類型 IPolicyRegistry<TKey> 和 IReadOnlyPolicyRegistry<TKey> 在服務集合中註冊所提供的 IPolicyRegistry<TKey>,並傳回所提供的登錄。Registers the provided IPolicyRegistry<TKey> in the service collection with service types IPolicyRegistry<TKey>, and IReadOnlyPolicyRegistry<TKey> and returns the provided registry. |
AddDistributedRedisCache(IServiceCollection, Action<RedisCacheOptions>) |
將 Redis 分散式快取服務新增至指定的 IServiceCollection。Adds Redis distributed caching services to the specified IServiceCollection. |
BuildServiceProvider(IServiceCollection) |
從所提供 IServiceCollection 建立包含服務的 ServiceProvider。Creates a ServiceProvider containing services from the provided IServiceCollection. |
BuildServiceProvider(IServiceCollection, ServiceProviderOptions) |
從所提供 IServiceCollection 建立包含服務的 ServiceProvider,選擇性地啟用服務建立和範圍驗證。Creates a ServiceProvider containing services from the provided IServiceCollection optionally enabling service-creation and scope validation. |
BuildServiceProvider(IServiceCollection, Boolean) |
從所提供 IServiceCollection 建立包含服務的 ServiceProvider,選擇性地啟用範圍驗證。Creates a ServiceProvider containing services from the provided IServiceCollection optionally enabling scope validation. |
AddHostedService<THostedService>(IServiceCollection) |
為指定的類型新增 IHostedService 註冊。Add an IHostedService registration for the given type. |
AddHostedService<THostedService>(IServiceCollection, Func<IServiceProvider,THostedService>) |
為指定的類型新增 IHostedService 註冊。Add an IHostedService registration for the given type. |
AddScoped(IServiceCollection, Type) |
將 |
AddScoped(IServiceCollection, Type, Func<IServiceProvider,Object>) |
將 |
AddScoped(IServiceCollection, Type, Type) |
將 |
AddScoped<TService>(IServiceCollection) |
將 |
AddScoped<TService>(IServiceCollection, Func<IServiceProvider,TService>) |
將 |
AddScoped<TService,TImplementation>(IServiceCollection) |
將 |
AddScoped<TService,TImplementation>(IServiceCollection, Func<IServiceProvider,TImplementation>) |
使用 |
AddSingleton(IServiceCollection, Type) |
將 |
AddSingleton(IServiceCollection, Type, Func<IServiceProvider,Object>) |
將 |
AddSingleton(IServiceCollection, Type, Object) |
將 |
AddSingleton(IServiceCollection, Type, Type) |
將 |
AddSingleton<TService>(IServiceCollection) |
將 |
AddSingleton<TService>(IServiceCollection, TService) |
將 |
AddSingleton<TService>(IServiceCollection, Func<IServiceProvider,TService>) |
將 |
AddSingleton<TService,TImplementation>(IServiceCollection) |
將 |
AddSingleton<TService,TImplementation>(IServiceCollection, Func<IServiceProvider,TImplementation>) |
使用 |
AddTransient(IServiceCollection, Type) |
將 |
AddTransient(IServiceCollection, Type, Func<IServiceProvider,Object>) |
將 |
AddTransient(IServiceCollection, Type, Type) |
將 |
AddTransient<TService>(IServiceCollection) |
將 |
AddTransient<TService>(IServiceCollection, Func<IServiceProvider,TService>) |
將 |
AddTransient<TService,TImplementation>(IServiceCollection) |
將 |
AddTransient<TService,TImplementation>(IServiceCollection, Func<IServiceProvider,TImplementation>) |
使用 |
AddDistributedSqlServerCache(IServiceCollection, Action<SqlServerCacheOptions>) |
將 Microsoft SQL Server 分散式快取服務新增至指定的 IServiceCollection。Adds Microsoft SQL Server distributed caching services to the specified IServiceCollection. |
AddStackExchangeRedisCache(IServiceCollection, Action<RedisCacheOptions>) |
將 Redis 分散式快取服務新增至指定的 IServiceCollection。Adds Redis distributed caching services to the specified IServiceCollection. |
CopyToDataTable<T>(IEnumerable<T>) |
根據輸入 DataTable 物件 (其中泛型參數 |
CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption) |
根據輸入 DataRow 物件 (其中泛型參數 |
CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption, FillErrorEventHandler) |
根據輸入 DataRow 物件 (其中泛型參數 |