ServiceLifetime 列舉

定義

指定服務在 IServiceCollection 中的存留期。

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

欄位

Scoped 1

指定將為每個範圍建立新服務執行個體。 在 ASP.NET Core 應用程式中,會在每個伺服器要求周圍建立範圍。

Singleton 0

指定將建立服務的單一執行個體。

Transient 2

指定在每次要求時建立服務的新執行個體。

適用於