Class Lifetime
Describes the lifetime of a service.
Implements
Inherited Members
Namespace: Solti.Utils.DI
Assembly: Solti.Utils.DI.dll
Syntax
public abstract class Lifetime : LifetimeBase
Constructors
Lifetime(Int32)
Creates a new instance.
Declaration
protected Lifetime(int precedence)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | precedence |
Properties
Pooled
Services having pooled lifetime are instantiated in a separate pool. Every IInjector may request a service instance from the pool which is automatically resetted and returned when the parent scope is disposed.
Declaration
public static Lifetime Pooled { get; }
Property Value
Type | Description |
---|---|
Lifetime |
Remarks
Pooled services should implement the IResettable interface.
Precedence
Precendence of this lifetime.
Declaration
public int Precedence { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
Scoped
Services having scoped liftime are instantiated only once (per scope) on the first request and disposed automatically when the parent scope is disposed.
Declaration
public static Lifetime Scoped { get; }
Property Value
Type | Description |
---|---|
Lifetime |
Singleton
Services having singleton liftime are instantiated only once in the root scope (on the first request) and disposed automatically when the root is released.
Declaration
public static Lifetime Singleton { get; }
Property Value
Type | Description |
---|---|
Lifetime |
Transient
Services having transient lifetime are instantiated on every request and released automatically when the parent scope is disposed.
Declaration
public static Lifetime Transient { get; }
Property Value
Type | Description |
---|---|
Lifetime |
Methods
CompareTo(LifetimeBase)
See System.IComparable`1.CompareTo(`0)
Declaration
public override int CompareTo(LifetimeBase other)
Parameters
Type | Name | Description |
---|---|---|
LifetimeBase | other |
Returns
Type | Description |
---|---|
System.Int32 |