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 中指定類型的範圍服務,新增至指定的 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,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.

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.

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,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.

AddSingleton<TService>(IServiceCollection)

TService 中指定類型的單一服務,新增至指定的 IServiceCollectionAdds a singleton service of the type specified in TService 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>(IServiceCollection, TService)

TService 中指定類型的單一服務,以及 implementationInstance 中指定的執行個體,新增至指定的 IServiceCollectionAdds a singleton service of the type specified in TService with an instance specified in implementationInstance 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,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.

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.

適用於