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
Public Class ServiceCollection
Implements ICollection(Of ServiceDescriptor), IEnumerable(Of ServiceDescriptor), IList(Of ServiceDescriptor), IServiceCollection
繼承
ServiceCollection
實作

建構函式

ServiceCollection()

屬性

Count
IsReadOnly
Item[Int32]

方法

Clear()
Contains(ServiceDescriptor)
CopyTo(ServiceDescriptor[], Int32)
Equals(Object)

判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object.

(繼承來源 Object)
GetEnumerator()
GetHashCode()

做為預設雜湊函式。Serves as the default hash function.

(繼承來源 Object)
GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(繼承來源 Object)
IndexOf(ServiceDescriptor)
Insert(Int32, ServiceDescriptor)
MemberwiseClone()

建立目前 Object 的淺層複本 (Shallow Copy)。Creates a shallow copy of the current Object.

(繼承來源 Object)
Remove(ServiceDescriptor)
RemoveAt(Int32)
ToString()

傳回代表目前物件的字串。Returns a string that represents the current object.

(繼承來源 Object)

明確介面實作

ICollection<ServiceDescriptor>.Add(ServiceDescriptor)
IEnumerable.GetEnumerator()

擴充方法

AddWebEncoders(IServiceCollection)

HtmlEncoderJavaScriptEncoderUrlEncoder 新增至指定的 servicesAdds HtmlEncoder, JavaScriptEncoder and UrlEncoder to the specified services.

AddWebEncoders(IServiceCollection, Action<WebEncoderOptions>)

HtmlEncoderJavaScriptEncoderUrlEncoder 新增至指定的 servicesAdds HtmlEncoder, JavaScriptEncoder and UrlEncoder to the specified services.

Add(IServiceCollection, ServiceDescriptor)

將指定的 descriptor 加入至 collectionAdds the specified descriptor to the collection.

Add(IServiceCollection, IEnumerable<ServiceDescriptor>)

ServiceDescriptor 的序列新增至 collectionAdds a sequence of ServiceDescriptor to the collection.

RemoveAll(IServiceCollection, Type)

移除 IServiceCollectionserviceType 類型的所有服務。Removes all services of type serviceType in IServiceCollection.

RemoveAll<T>(IServiceCollection)

移除 IServiceCollectionT 類型的所有服務。Removes all services of type T in IServiceCollection.

Replace(IServiceCollection, ServiceDescriptor)

移除 IServiceCollection 中具有與 descriptor 相同服務類型的第一個服務,並將 descriptor 新增至集合。Removes the first service in IServiceCollection with the same service type as descriptor and adds descriptor to the collection.

TryAdd(IServiceCollection, ServiceDescriptor)

如果尚未註冊服務類型,則將指定的 descriptor 新增至 collectionAdds the specified descriptor to the collection if the service type hasn't already been registered.

TryAdd(IServiceCollection, IEnumerable<ServiceDescriptor>)

如果尚未註冊服務類型,則將指定的 descriptors 新增至 collectionAdds the specified descriptors to the collection if the service type hasn't already been registered.

TryAddEnumerable(IServiceCollection, ServiceDescriptor)

如果現有描述項具有相同的 ServiceType,以及尚未存在於 services.. 中的實作,則新增 ServiceDescriptorAdds a ServiceDescriptor if an existing descriptor with the same ServiceType and an implementation that does not already exist in services...

TryAddEnumerable(IServiceCollection, IEnumerable<ServiceDescriptor>)

如果現有描述項具有相同的 ServiceType,以及尚未存在於 services.. 中的實作,則新增特定的 ServiceDescriptorAdds the specified ServiceDescriptors if an existing descriptor with the same ServiceType and an implementation that does not already exist in services...

TryAddScoped(IServiceCollection, Type)

如果尚未註冊服務類型,則將指定的 service 作為 Scoped 服務新增至 collectionAdds the specified service as a Scoped service to the collection if the service type hasn't already been registered.

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

如果尚未註冊服務類型,則使用 implementationFactory 中指定的 Factory,將指定的 service 作為 Scoped 服務新增至 collectionAdds the specified service as a Scoped service using the factory specified in implementationFactory to the collection if the service type hasn't already been registered.

TryAddScoped(IServiceCollection, Type, Type)

如果尚未註冊服務類型,則將所指定 service 作為具有 implementationTypeScoped 服務新增至 collectionAdds the specified service as a Scoped service with the implementationType implementation to the collection if the service type hasn't already been registered.

TryAddScoped<TService>(IServiceCollection)

如果尚未註冊服務類型,則將指定的 TService 作為 Scoped 服務新增至 collectionAdds the specified TService as a Scoped service to the collection if the service type hasn't already been registered.

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

如果尚未註冊服務類型,則使用 implementationFactory 中指定的 Factory,將指定的 TService 作為 Scoped 服務新增至 servicesAdds the specified TService as a Scoped service using the factory specified in implementationFactory to the services if the service type hasn't already been registered.

TryAddScoped<TService,TImplementation>(IServiceCollection)

如果尚未註冊服務類型,則將指定 TService 作為 TImplementation 中指定的 Scoped 服務實作類型新增至 collectionAdds the specified TService as a Scoped service implementation type specified in TImplementation to the collection if the service type hasn't already been registered.

TryAddSingleton(IServiceCollection, Type)

如果尚未註冊服務類型,則將指定的 service 作為 Singleton 服務新增至 collectionAdds the specified service as a Singleton service to the collection if the service type hasn't already been registered.

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

如果尚未註冊服務類型,則使用 implementationFactory 中指定的 Factory,將指定的 service 作為 Singleton 服務新增至 collectionAdds the specified service as a Singleton service using the factory specified in implementationFactory to the collection if the service type hasn't already been registered.

TryAddSingleton(IServiceCollection, Type, Type)

如果尚未註冊服務類型,則將所指定 service 作為具有 implementationTypeSingleton 服務新增至 collectionAdds the specified service as a Singleton service with the implementationType implementation to the collection if the service type hasn't already been registered.

TryAddSingleton<TService>(IServiceCollection)

如果尚未註冊服務類型,則將指定的 TService 作為 Singleton 服務新增至 collectionAdds the specified TService as a Singleton service to the collection if the service type hasn't already been registered.

TryAddSingleton<TService>(IServiceCollection, TService)

如果尚未註冊服務類型,則使用 instance 中指定的執行個體,將指定的 TService 作為 Singleton 服務新增至 collectionAdds the specified TService as a Singleton service with an instance specified in instance to the collection if the service type hasn't already been registered.

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

如果尚未註冊服務類型,則使用 implementationFactory 中指定的 Factory,將指定的 TService 作為 Singleton 服務新增至 servicesAdds the specified TService as a Singleton service using the factory specified in implementationFactory to the services if the service type hasn't already been registered.

TryAddSingleton<TService,TImplementation>(IServiceCollection)

如果尚未註冊服務類型,則將指定 TService 作為 TImplementation 中指定的 Singleton 服務實作類型新增至 collectionAdds the specified TService as a Singleton service implementation type specified in TImplementation to the collection if the service type hasn't already been registered.

TryAddTransient(IServiceCollection, Type)

如果尚未註冊服務類型,則將指定的 service 作為 Transient 服務新增至 collectionAdds the specified service as a Transient service to the collection if the service type hasn't already been registered.

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

如果尚未註冊服務類型,則使用 implementationFactory 中指定的 Factory,將指定的 service 作為 Transient 服務新增至 collectionAdds the specified service as a Transient service using the factory specified in implementationFactory to the collection if the service type hasn't already been registered.

TryAddTransient(IServiceCollection, Type, Type)

如果尚未註冊服務類型,則將所指定 service 作為具有 implementationTypeTransient 服務新增至 collectionAdds the specified service as a Transient service with the implementationType implementation to the collection if the service type hasn't already been registered.

TryAddTransient<TService>(IServiceCollection)

如果尚未註冊服務類型,則將指定的 TService 作為 Transient 服務新增至 collectionAdds the specified TService as a Transient service to the collection if the service type hasn't already been registered.

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

如果尚未註冊服務類型,則使用 implementationFactory 中指定的 Factory,將指定的 TService 作為 Transient 服務新增至 servicesAdds the specified TService as a Transient service using the factory specified in implementationFactory to the services if the service type hasn't already been registered.

TryAddTransient<TService,TImplementation>(IServiceCollection)

如果尚未註冊服務類型,則將指定 TService 作為 TImplementation 中指定的 Transient 服務實作類型新增至 collectionAdds the specified TService as a Transient service implementation type specified in TImplementation to the collection if the service type hasn't already been registered.

AddHealthChecks(IServiceCollection)

使用提供的委派來註冊健康狀態檢查,以將 HealthCheckService 新增至容器。Adds the HealthCheckService to the container, using the provided delegate to register health checks.

AddHttpClient(IServiceCollection)

IHttpClientFactory 和相關服務新增至 IServiceCollectionAdds the IHttpClientFactory and related services to the IServiceCollection.

AddHttpClient(IServiceCollection, String)

IHttpClientFactory 和相關服務新增至 IServiceCollection,並設定具名 HttpClientAdds the IHttpClientFactory and related services to the IServiceCollection and configures a named HttpClient.

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

IHttpClientFactory 和相關服務新增至 IServiceCollection,並設定具名 HttpClientAdds the IHttpClientFactory and related services to the IServiceCollection and configures a named HttpClient.

AddHttpClient(IServiceCollection, String, Action<HttpClient>)

IHttpClientFactory 和相關服務新增至 IServiceCollection,並設定具名 HttpClientAdds the IHttpClientFactory and related services to the IServiceCollection and configures a named HttpClient.

AddHttpClient<TClient>(IServiceCollection)

IHttpClientFactory 和相關服務新增至 IServiceCollection,並設定 TClient 類型與具名 HttpClient 之間的繫結。Adds the IHttpClientFactory and related services to the IServiceCollection and configures a binding between the TClient type and a named HttpClient. 用戶端名稱將會設定為 TClient 的完整名稱。The client name will be set to the full name of TClient.

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

IHttpClientFactory 和相關服務新增至 IServiceCollection,並設定 TClient 類型與具名 HttpClient 之間的繫結。Adds the IHttpClientFactory and related services to the IServiceCollection and configures a binding between the TClient type and a named HttpClient. 用戶端名稱將會設定為 TClient 的類型名稱。The client name will be set to the type name of TClient.

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

IHttpClientFactory 和相關服務新增至 IServiceCollection,並設定 TClient 類型與具名 HttpClient 之間的繫結。Adds the IHttpClientFactory and related services to the IServiceCollection and configures a binding between the TClient type and a named HttpClient. 用戶端名稱將會設定為 TClient 的類型名稱。The client name will be set to the type name of TClient.

AddHttpClient<TClient>(IServiceCollection, String)

IHttpClientFactory 和相關服務新增至 IServiceCollection,並設定 TClient 類型與具名 HttpClient 之間的繫結。Adds the IHttpClientFactory and related services to the IServiceCollection and configures a binding between the TClient type and a named HttpClient.

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

IHttpClientFactory 和相關服務新增至 IServiceCollection,並設定 TClient 類型與具名 HttpClient 之間的繫結。Adds the IHttpClientFactory and related services to the IServiceCollection and configures a binding between the TClient type and a named HttpClient.

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

IHttpClientFactory 和相關服務新增至 IServiceCollection,並設定 TClient 類型與具名 HttpClient 之間的繫結。Adds the IHttpClientFactory and related services to the IServiceCollection and configures a binding between the TClient type and a named HttpClient.

AddHttpClient<TClient,TImplementation>(IServiceCollection)

IHttpClientFactory 和相關服務新增至 IServiceCollection,並設定 TClient 類型與具名 HttpClient 之間的繫結。Adds the IHttpClientFactory and related services to the IServiceCollection and configures a binding between the TClient type and a named HttpClient. 用戶端名稱將會設定為 TClient 的類型名稱。The client name will be set to the type name of TClient.

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

IHttpClientFactory 和相關服務新增至 IServiceCollection,並設定 TClient 類型與具名 HttpClient 之間的繫結。Adds the IHttpClientFactory and related services to the IServiceCollection and configures a binding between the TClient type and a named HttpClient. 用戶端名稱將會設定為 TClient 的類型名稱。The client name will be set to the type name of TClient.

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

IHttpClientFactory 和相關服務新增至 IServiceCollection,並設定 TClient 類型與具名 HttpClient 之間的繫結。Adds the IHttpClientFactory and related services to the IServiceCollection and configures a binding between the TClient type and a named HttpClient. 用戶端名稱將會設定為 TClient 的類型名稱。The client name will be set to the type name of TClient.

AddHttpClient<TClient,TImplementation>(IServiceCollection, String)

IHttpClientFactory 和相關服務新增至 IServiceCollection,並設定 TClient 類型與具名 HttpClient 之間的繫結。Adds the IHttpClientFactory and related services to the IServiceCollection and configures a binding between the TClient type and a named HttpClient. 用戶端名稱將會設定為 TClient 的類型名稱。The client name will be set to the type name of TClient.

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

IHttpClientFactory 和相關服務新增至 IServiceCollection,並設定 TClient 類型與具名 HttpClient 之間的繫結。Adds the IHttpClientFactory and related services to the IServiceCollection and configures a binding between the TClient type and a named HttpClient.

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

IHttpClientFactory 和相關服務新增至 IServiceCollection,並設定 TClient 類型與具名 HttpClient 之間的繫結。Adds the IHttpClientFactory and related services to the IServiceCollection and configures a binding between the TClient type and a named HttpClient.

AddLocalization(IServiceCollection)

新增應用程式當地語系化所需的服務。Adds services required for application localization.

AddLocalization(IServiceCollection, Action<LocalizationOptions>)

新增應用程式當地語系化所需的服務。Adds services required for application localization.

AddLogging(IServiceCollection)

將記錄服務新增至指定的 IServiceCollectionAdds logging services to the specified IServiceCollection.

AddLogging(IServiceCollection, Action<ILoggingBuilder>)

將記錄服務新增至指定的 IServiceCollectionAdds logging services to the specified IServiceCollection.

AddDistributedMemoryCache(IServiceCollection)

新增 IDistributedCache 的預設實作,將記憶體中的項目儲存至 IServiceCollectionAdds 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 的預設實作,將記憶體中的項目儲存至 IServiceCollectionAdds 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 的非分散式記憶體內實作新增至 IServiceCollectionAdds a non distributed in memory implementation of IMemoryCache to the IServiceCollection.

AddMemoryCache(IServiceCollection, Action<MemoryCacheOptions>)

IMemoryCache 的非分散式記憶體內實作新增至 IServiceCollectionAdds a non distributed in memory implementation of IMemoryCache to the IServiceCollection.

Configure<TOptions>(IServiceCollection, IConfiguration)

註冊 TOptions 將繫結的組態執行個體。Registers a configuration instance which TOptions will bind against.

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)

取得會將相同 TOptions 之設定呼叫轉送至基礎服務集合的選項建立器。Gets an options builder that forwards Configure calls for the same TOptions to the underlying service collection.

AddOptions<TOptions>(IServiceCollection, String)

取得會將相同具名 TOptions 之設定呼叫轉送至基礎服務集合的選項建立器。Gets an options builder that forwards Configure calls for the same named TOptions to the underlying service collection.

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

註冊用來設定特定選項類型的動作。Registers an action used to configure a particular type of options. 注意:這些會在所有操作前執行Note: These are run before all 執行個體時提供 SQL Server 登入。.

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

註冊用來設定特定選項類型的動作。Registers an action used to configure a particular type of options. 注意:這些會在所有操作前執行Note: These are run before all 執行個體時提供 SQL Server 登入。.

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

註冊用於設定特定選項類型的所有執行個體動作。Registers an action used to configure all instances of a particular type of options.

ConfigureOptions(IServiceCollection, Object)

註冊將會註冊其所有 I[Post]ConfigureOptions 的物件。Registers an object that will have all of its I[Post]ConfigureOptions registered.

ConfigureOptions(IServiceCollection, Type)

註冊將會註冊其所有 I[Post]ConfigureOptions 的類型。Registers a type that will have all of its I[Post]ConfigureOptions registered.

ConfigureOptions<TConfigureOptions>(IServiceCollection)

註冊將會註冊其所有 I[Post]ConfigureOptions 的類型。Registers a type that will have all of its I[Post]ConfigureOptions registered.

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

註冊用於初始化特定類型選項的動作。Registers an action used to initialize a particular type of options. 注意:這些會在所有操作後執行Note: These are run after all 執行個體時提供 SQL Server 登入。.

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

註冊用來設定特定選項類型的動作。Registers an action used to configure a particular type of options. 注意:這些會在所有操作後執行Note: These are run after all 執行個體時提供 SQL Server 登入。.

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

註冊用於張貼設定特定選項類型的所有執行個體動作。Registers an action used to post configure all instances of a particular type of options. 注意:這些會在所有操作後執行Note: These are run after all 執行個體時提供 SQL Server 登入。.

AddPolicyRegistry(IServiceCollection)

使用服務類型 Polly.Registry.IPolicyRegistry`1Polly.Registry.IReadOnlyPolicyRegistry`1 在服務集合中註冊空白 Polly.Registry.PolicyRegistry,並傳回新建立的登錄。Registers an empty Polly.Registry.PolicyRegistry in the service collection with service types Polly.Registry.IPolicyRegistry`1, and Polly.Registry.IReadOnlyPolicyRegistry`1 and returns the newly created registry.

AddPolicyRegistry(IServiceCollection, IPolicyRegistry<String>)

使用服務類型 Polly.Registry.IPolicyRegistry`1Polly.Registry.IReadOnlyPolicyRegistry`1 在服務集合中註冊所提供的 Polly.Registry.IPolicyRegistry`1,並傳回所提供的登錄。Registers the provided Polly.Registry.IPolicyRegistry`1 in the service collection with service types Polly.Registry.IPolicyRegistry`1, and Polly.Registry.IReadOnlyPolicyRegistry`1 and returns the provided registry.

AddDistributedRedisCache(IServiceCollection, Action<RedisCacheOptions>)

將 Redis 分散式快取服務新增至指定的 IServiceCollectionAdds Redis distributed caching services to the specified IServiceCollection.

BuildServiceProvider(IServiceCollection)

從所提供 IServiceCollection 建立包含服務的 ServiceProviderCreates a ServiceProvider containing services from the provided IServiceCollection.

BuildServiceProvider(IServiceCollection, ServiceProviderOptions)

從所提供 IServiceCollection 建立包含服務的 ServiceProvider,選擇性地啟用範圍驗證。Creates a ServiceProvider containing services from the provided IServiceCollection optionally enabling 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)

serviceType 中指定類型的範圍服務,新增至指定的 IServiceCollectionAdds a scoped service of the type specified in serviceType to the specified IServiceCollection.

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

serviceType 中指定類型的範圍服務,以及 implementationFactory 中指定的 Factory,新增至指定的 IServiceCollectionAdds a scoped service of the type specified in serviceType with a factory specified in implementationFactory to the specified IServiceCollection.

AddScoped(IServiceCollection, Type, Type)

serviceType 中指定類型的範圍服務,以及在 implementationType 中指定類型的實作,新增至指定的 IServiceCollectionAdds a scoped service of the type specified in serviceType with an implementation of the type specified in implementationType to the specified IServiceCollection.

AddScoped<TService>(IServiceCollection)

TService 中指定類型的範圍服務,新增至指定的 IServiceCollectionAdds a scoped service of the type specified in TService to the specified IServiceCollection.

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

TService 中指定類型的範圍服務,以及 implementationFactory 中指定的 Factory,新增至指定的 IServiceCollectionAdds a scoped service of the type specified in TService with a factory specified in implementationFactory to the specified IServiceCollection.

AddScoped<TService,TImplementation>(IServiceCollection)

TService 中指定類型的範圍服務,以及在 TImplementation 中指定的實作類型,新增至指定的 IServiceCollectionAdds a scoped service of the type specified in TService with an implementation type specified in TImplementation to the specified IServiceCollection.

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

使用 implementationFactory 中指定的 Factory,將 TService 中指定類型的範圍服務,以及 TImplementation 中指定的實作類型,新增至指定的 IServiceCollectionAdds a scoped service of the type specified in TService with an implementation type specified in TImplementation using the factory specified in implementationFactory to the specified IServiceCollection.

AddSingleton(IServiceCollection, Type)

serviceType 中指定類型的單一服務,新增至指定的 IServiceCollectionAdds a singleton service of the type specified in serviceType to the specified IServiceCollection.

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

serviceType 中指定類型的單一服務,以及 implementationFactory 中指定的 Factory,新增至指定的 IServiceCollectionAdds a singleton service of the type specified in serviceType with a factory specified in implementationFactory to the specified IServiceCollection.

AddSingleton(IServiceCollection, Type, Object)

serviceType 中指定類型的單一服務,以及 implementationInstance 中指定的執行個體,新增至指定的 IServiceCollectionAdds a singleton service of the type specified in serviceType with an instance specified in implementationInstance to the specified IServiceCollection.

AddSingleton(IServiceCollection, Type, Type)

serviceType 中指定類型的單一服務,以及在 implementationType 中指定類型的實作,新增至指定的 IServiceCollectionAdds a singleton service of the type specified in serviceType with an implementation of the type specified in implementationType to the specified IServiceCollection.

AddSingleton<TService>(IServiceCollection)

TService 中指定類型的單一服務,新增至指定的 IServiceCollectionAdds a singleton service of the type specified in TService to the specified IServiceCollection.

AddSingleton<TService>(IServiceCollection, TService)

TService 中指定類型的單一服務,以及 implementationInstance 中指定的執行個體,新增至指定的 IServiceCollectionAdds a singleton service of the type specified in TService with an instance specified in implementationInstance to the specified IServiceCollection.

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

TService 中指定類型的單一服務,以及 implementationFactory 中指定的 Factory,新增至指定的 IServiceCollectionAdds a singleton service of the type specified in TService with a factory specified in implementationFactory to the specified IServiceCollection.

AddSingleton<TService,TImplementation>(IServiceCollection)

TService 中指定類型的單一服務,以及在 TImplementation 中指定的實作類型,新增至指定的 IServiceCollectionAdds a singleton service of the type specified in TService with an implementation type specified in TImplementation to the specified IServiceCollection.

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

使用 implementationFactory 中指定的 Factory,將 TService 中指定類型的單一服務,以及 TImplementation 中指定的實作類型,新增至指定的 IServiceCollectionAdds a singleton service of the type specified in TService with an implementation type specified in TImplementation using the factory specified in implementationFactory to the specified IServiceCollection.

AddTransient(IServiceCollection, Type)

serviceType 中指定類型的暫時性服務,新增至指定的 IServiceCollectionAdds a transient service of the type specified in serviceType to the specified IServiceCollection.

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

serviceType 中指定類型的暫時性服務,以及 implementationFactory 中指定的 Factory,新增至指定的 IServiceCollectionAdds a transient service of the type specified in serviceType with a factory specified in implementationFactory to the specified IServiceCollection.

AddTransient(IServiceCollection, Type, Type)

serviceType 中指定類型的暫時性服務,以及在 implementationType 中指定類型的實作,新增至指定的 IServiceCollectionAdds a transient service of the type specified in serviceType with an implementation of the type specified in implementationType to the specified IServiceCollection.

AddTransient<TService>(IServiceCollection)

TService 中指定類型的暫時性服務,新增至指定的 IServiceCollectionAdds a transient service of the type specified in TService to the specified IServiceCollection.

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

TService 中指定類型的暫時性服務,以及 implementationFactory 中指定的 Factory,新增至指定的 IServiceCollectionAdds a transient service of the type specified in TService with a factory specified in implementationFactory to the specified IServiceCollection.

AddTransient<TService,TImplementation>(IServiceCollection)

TService 中指定類型的暫時性服務,以及在 TImplementation 中指定的實作類型,新增至指定的 IServiceCollectionAdds a transient service of the type specified in TService with an implementation type specified in TImplementation to the specified IServiceCollection.

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

使用 implementationFactory 中指定的 Factory,將 TService 中指定類型的暫時性服務,以及 TImplementation 中指定的實作類型,新增至指定的 IServiceCollectionAdds a transient service of the type specified in TService with an implementation type specified in TImplementation using the factory specified in implementationFactory to the specified IServiceCollection.

AddDistributedSqlServerCache(IServiceCollection, Action<SqlServerCacheOptions>)

將 Microsoft SQL Server 分散式快取服務新增至指定的 IServiceCollectionAdds Microsoft SQL Server distributed caching services to the specified IServiceCollection.

AddStackExchangeRedisCache(IServiceCollection, Action<RedisCacheOptions>)

將 Redis 分散式快取服務新增至指定的 IServiceCollectionAdds Redis distributed caching services to the specified IServiceCollection.

CopyToDataTable<T>(IEnumerable<T>)

根據輸入 DataTable 物件 (其中泛型參數 TDataRow) 傳回包含 IEnumerable<T> 物件複本的 DataRowReturns a DataTable that contains copies of the DataRow objects, given an input IEnumerable<T> object where the generic parameter T is DataRow.

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

根據輸入 DataRow 物件 (其中泛型參數 TDataTable),將 IEnumerable<T> 物件複製到指定的 DataRowCopies DataRow objects to the specified DataTable, given an input IEnumerable<T> object where the generic parameter T is DataRow.

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

根據輸入 DataRow 物件 (其中泛型參數 TDataTable),將 IEnumerable<T> 物件複製到指定的 DataRowCopies DataRow objects to the specified DataTable, given an input IEnumerable<T> object where the generic parameter T is DataRow.

適用於