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.

适用于