ServiceCollectionServiceExtensions 类

定义

用于在 IServiceCollection 中添加服务的扩展方法。Extension methods for adding services to an IServiceCollection.

public ref class ServiceCollectionServiceExtensions abstract sealed
public static class ServiceCollectionServiceExtensions
type ServiceCollectionServiceExtensions = class
Public Module ServiceCollectionServiceExtensions
继承
ServiceCollectionServiceExtensions

方法

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

使用 implementationFactory 中指定的中心将 serviceType 中指定类型的范围内的服务添加到指定的 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,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>)

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

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

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

使用 implementationFactory 中指定的中心将 serviceType 中指定类型的单一实例服务添加到指定的 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,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>)

使用 implementationFactory 中指定的中心将 TService 中指定类型的单一实例服务和 TImplementation 中指定类型的实现添加到指定的 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.

AddSingleton<TService>(IServiceCollection)

TService 中指定类型的单一实例服务添加到指定的 IServiceCollection 中。Adds a singleton service of the type specified in TService to the specified IServiceCollection.

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

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

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

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

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

使用 implementationFactory 中指定的中心将 TService 中指定类型的暂时性服务和 TImplementation 中指定类型的实现添加到指定的 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.

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

使用 implementationFactory 中指定的中心将 TService 中指定类型的暂时性服务添加到指定的 IServiceCollection 中。Adds a transient service of the type specified in TService with a factory specified in implementationFactory to the specified IServiceCollection.

适用于