IServiceCollection Interface

Definition

为服务描述符集合指定协定。Specifies the contract for a collection of service descriptors.

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

Properties

Count

获取 ICollection<T> 中包含的元素数。Gets the number of elements contained in the ICollection<T>.

(Inherited from ICollection<T>)
IsReadOnly

获取一个值,用于指示 ICollection<T> 是否为只读。Gets a value indicating whether the ICollection<T> is read-only.

(Inherited from ICollection<T>)
Item[Int32]

获取或设置指定索引处的元素。Gets or sets the element at the specified index.

(Inherited from IList<T>)

Methods

Add(T)

将项添加到 ICollection<T> 中。Adds an item to the ICollection<T>.

(Inherited from ICollection<T>)
Clear()

ICollection<T> 中移除所有项。Removes all items from the ICollection<T>.

(Inherited from ICollection<T>)
Contains(T)

确定 ICollection<T> 是否包含特定值。Determines whether the ICollection<T> contains a specific value.

(Inherited from ICollection<T>)
CopyTo(T[], Int32)

从特定的 ICollection<T> 索引开始,将 Array 的元素复制到一个 Array 中。Copies the elements of the ICollection<T> to an Array, starting at a particular Array index.

(Inherited from ICollection<T>)
GetEnumerator()

返回循环访问集合的枚举器。Returns an enumerator that iterates through a collection.

(Inherited from IEnumerable)
IndexOf(T)

确定 IList<T> 中特定项的索引。Determines the index of a specific item in the IList<T>.

(Inherited from IList<T>)
Insert(Int32, T)

将项插入到 IList<T> 中的指定索引处。Inserts an item to the IList<T> at the specified index.

(Inherited from IList<T>)
Remove(T)

ICollection<T> 中删除特定对象的第一个匹配项。Removes the first occurrence of a specific object from the ICollection<T>.

(Inherited from ICollection<T>)
RemoveAt(Int32)

移除位于指定索引处的 IList<T> 项。Removes the IList<T> item at the specified index.

(Inherited from IList<T>)

Extension Methods

AddWebEncoders(IServiceCollection)

HtmlEncoderJavaScriptEncoderUrlEncoder 添加到指定的 services 中。Adds HtmlEncoder, JavaScriptEncoder and UrlEncoder to the specified services.

AddWebEncoders(IServiceCollection, Action<WebEncoderOptions>)

HtmlEncoderJavaScriptEncoderUrlEncoder 添加到指定的 services 中。Adds HtmlEncoder, JavaScriptEncoder and UrlEncoder to the specified services.

Add(IServiceCollection, ServiceDescriptor)

将指定的 descriptor 添加到 collectionAdds the specified descriptor to the collection.

Add(IServiceCollection, IEnumerable<ServiceDescriptor>)

ServiceDescriptor 序列添加到 collection 中。Adds a sequence of ServiceDescriptor to the collection.

RemoveAll(IServiceCollection, Type)

删除 serviceType 中所有 IServiceCollection 类型的服务。Removes all services of type serviceType in IServiceCollection.

RemoveAll<T>(IServiceCollection)

删除 T 中所有 IServiceCollection 类型的服务。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 添加到 collection 中。Adds the specified descriptor to the collection if the service type hasn't already been registered.

TryAdd(IServiceCollection, IEnumerable<ServiceDescriptor>)

如果服务类型尚未注册,则将指定的 descriptors 添加到 collection 中。Adds the specified descriptors to the collection if the service type hasn't already been registered.

TryAddEnumerable(IServiceCollection, ServiceDescriptor)

如果现有描述符具有相同 ServiceDescriptorServiceType 中尚不存在的实现,则添加 services..Adds a ServiceDescriptor if an existing descriptor with the same ServiceType and an implementation that does not already exist in services...

TryAddEnumerable(IServiceCollection, IEnumerable<ServiceDescriptor>)

如果现有描述符具有相同 ServiceDescriptorServiceType 中尚不存在的实现,则添加指定的 services..Adds 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 服务添加到 collection 中。Adds 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>)

如果服务类型尚未注册,则使用 service 中指定的中心将指定的 Scoped 作为 implementationFactory 服务添加到 collection 中。Adds 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 实现将指定的 Scoped 作为 implementationType 服务添加到 collection 中。Adds 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 服务添加到 collection 中。Adds 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>)

如果服务类型尚未注册,则使用 TService 中指定的中心将指定的 Scoped 作为 implementationFactory 服务添加到 services 中。Adds 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 作为 Scoped 中指定的 TImplementation 服务实现类型添加到 collection 中。Adds 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 服务添加到 collection 中。Adds 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>)

如果服务类型尚未注册,则使用 service 中指定的中心将指定的 Singleton 作为 implementationFactory 服务添加到 collection 中。Adds 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 实现将指定的 Singleton 作为 implementationType 服务添加到 collection 中。Adds 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 服务添加到 collection 中。Adds the specified TService as a Singleton service to the collection if the service type hasn't already been registered.

TryAddSingleton<TService>(IServiceCollection, TService)

如果服务类型尚未注册,则将指定的 TService 作为包含 Singleton 中指定的实例的 instance 服务添加到 collection 中。Adds 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>)

如果服务类型尚未注册,则使用 TService 中指定的中心将指定的 Singleton 作为 implementationFactory 服务添加到 services 中。Adds 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 作为 Singleton 中指定的 TImplementation 服务实现类型添加到 collection 中。Adds 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 服务添加到 collection 中。Adds 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>)

如果服务类型尚未注册,则使用 service 中指定的中心将指定的 Transient 作为 implementationFactory 服务添加到 collection 中。Adds 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 实现将指定的 Transient 作为 implementationType 服务添加到 collection 中。Adds 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 服务添加到 collection 中。Adds 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>)

如果服务类型尚未注册,则使用 TService 中指定的中心将指定的 Transient 作为 implementationFactory 服务添加到 services 中。Adds 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 作为 Transient 中指定的 TImplementation 服务实现类型添加到 collection 中。Adds 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 的默认实现,该实现将内存中的项存储到 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)

注册将对其绑定 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 .

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

注册用于配置特定类型的选项的操作。Registers an action used to configure a particular type of options. 注意:这些操作运行之后才会运行所有Note: These are run before all .

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 .

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

注册用于配置特定类型的选项的操作。Registers an action used to configure a particular type of options. 注意:这些操作都在以下所有内容之后运行Note: These are run after all .

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 .

AddPolicyRegistry(IServiceCollection)

在服务集合中使用服务类型 Polly.Registry.PolicyRegistryPolly.Registry.IPolicyRegistry`1 注册空的 Polly.Registry.IReadOnlyPolicyRegistry`1,并返回新创建的注册表。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.IPolicyRegistry`1 注册提供的 Polly.Registry.IReadOnlyPolicyRegistry`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)

创建一个 ServiceProvider,它包含提供的 IServiceCollection 中的服务。Creates a ServiceProvider containing services from the provided IServiceCollection.

BuildServiceProvider(IServiceCollection, ServiceProviderOptions)

创建一个 ServiceProvider,它包含提供的 IServiceCollection 中的服务,并且可选择启用服务创建和范围验证。Creates a ServiceProvider containing services from the provided IServiceCollection optionally enabling service-creation and scope validation.

BuildServiceProvider(IServiceCollection, Boolean)

创建一个 ServiceProvider,它包含提供的 IServiceCollection 中的服务,并且可以选择启用范围验证。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 中指定类型的范围内的服务添加到指定的 IServiceCollection 中。Adds a scoped service of the type specified in serviceType to the specified IServiceCollection.

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

使用 serviceType 中指定的中心将 implementationFactory 中指定类型的范围内的服务添加到指定的 IServiceCollection 中。Adds 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 中指定类型的实现添加到指定的 IServiceCollection 中。Adds 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 中指定类型的范围内的服务添加到指定的 IServiceCollection 中。Adds a scoped service of the type specified in TService to the specified IServiceCollection.

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

使用 TService 中指定的中心将 implementationFactory 中指定类型的范围内的服务添加到指定的 IServiceCollection 中。Adds 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 中指定类型的实现添加到指定的 IServiceCollection 中。Adds 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>)

使用 TService 中指定的中心将 TImplementation 中指定类型的范围内的服务和 implementationFactory 中指定类型的实现添加到指定的 IServiceCollection 中。Adds 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 中指定类型的单一实例服务添加到指定的 IServiceCollection 中。Adds a singleton service of the type specified in serviceType to the specified IServiceCollection.

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

使用 serviceType 中指定的中心将 implementationFactory 中指定类型的单一实例服务添加到指定的 IServiceCollection 中。Adds 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 中指定的实例添加到指定的 IServiceCollection 中。Adds 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 中指定类型的实现添加到指定的 IServiceCollection 中。Adds 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 中指定类型的单一实例服务添加到指定的 IServiceCollection 中。Adds a singleton service of the type specified in TService to the specified IServiceCollection.

AddSingleton<TService>(IServiceCollection, TService)

TService 中指定类型的单一实例服务和 implementationInstance 中指定的实例添加到指定的 IServiceCollection 中。Adds 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 中指定类型的单一实例服务添加到指定的 IServiceCollection 中。Adds 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 中指定类型的实现添加到指定的 IServiceCollection 中。Adds 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>)

使用 TService 中指定的中心将 TImplementation 中指定类型的单一实例服务和 implementationFactory 中指定类型的实现添加到指定的 IServiceCollection 中。Adds 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 中指定类型的暂时性服务添加到指定的 IServiceCollection 中。Adds a transient service of the type specified in serviceType to the specified IServiceCollection.

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

使用 serviceType 中指定的中心将 implementationFactory 中指定类型的暂时性服务添加到指定的 IServiceCollection 中。Adds 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 中指定类型的实现添加到指定的 IServiceCollection 中。Adds 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 中指定类型的暂时性服务添加到指定的 IServiceCollection 中。Adds a transient service of the type specified in TService to the specified IServiceCollection.

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

使用 TService 中指定的中心将 implementationFactory 中指定类型的暂时性服务添加到指定的 IServiceCollection 中。Adds 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 中指定类型的暂时性服务添加到指定的 IServiceCollection 中。Adds 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>)

使用 TService 中指定的中心将 TImplementation 中指定类型的暂时性服务和 implementationFactory 中指定类型的实现添加到指定的 IServiceCollection 中。Adds 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 分布式缓存服务添加到指定的 IServiceCollection 中。Adds 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>)

在给定其泛型参数 TDataTable 的输入 DataRow 对象的情况下,返回包含 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)

在给定其泛型参数 TDataRow 的输入 DataTable 对象的情况下,将 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)

在给定其泛型参数 TDataRow 的输入 DataTable 对象的情况下,将 IEnumerable<T> 对象复制到指定的 DataRowCopies DataRow objects to the specified DataTable, given an input IEnumerable<T> object where the generic parameter T is DataRow.

Applies to