ServiceLifetime 列舉

定義

指定服務在 IServiceCollection 中的存留期。Specifies the lifetime of a service in an IServiceCollection.

public enum class ServiceLifetime
public enum ServiceLifetime
type ServiceLifetime = 
Public Enum ServiceLifetime
繼承
ServiceLifetime

欄位

Scoped 1

指定將為每個範圍建立新服務執行個體。Specifies that a new instance of the service will be created for each scope.

Singleton 0

指定將建立服務的單一執行個體。Specifies that a single instance of the service will be created.

Transient 2

指定在每次要求時建立服務的新執行個體。Specifies that a new instance of the service will be created every time it is requested.

適用於