SimpleInjectorLifestyle
SimpleInjector.LifestylesSingletonLifestyle
SimpleInjectorScopedLifestyle
Namespace: SimpleInjector
Assembly: SimpleInjector (in SimpleInjector.dll) Version: 5.3.0
The Lifestyle type exposes the following members.
Name | Description | |
---|---|---|
Lifestyle | Initializes a new instance of the Lifestyle class. |
Name | Description | |
---|---|---|
Length |
Gets the length of the lifestyle. Implementers must implement this property. The diagnostic
services use this value to compare lifestyles with each other to determine lifestyle
misconfigurations.
| |
Name | Gets the user friendly name of this lifestyle. |
Name | Description | |
---|---|---|
CreateCustom |
Creates a custom lifestyle using the supplied lifestyleApplierFactory delegate.
| |
CreateHybrid(ScopedLifestyle, Lifestyle) |
The hybrid lifestyle allows mixing two lifestyles in a single registration. The hybrid will use
the defaultLifestyle in case its
GetCurrentScope method returns a
scope; otherwise the fallbackLifestyle is used. The hybrid lifestyle will
redirect the creation of the instance to the selected lifestyle. By nesting hybrid lifestyles,
any number of lifestyles can be mixed.
| |
CreateHybrid(ScopedLifestyle, ScopedLifestyle) |
The hybrid lifestyle allows mixing two lifestyles in a single registration. The hybrid will use
the defaultLifestyle in case its
GetCurrentScope method returns a
scope; otherwise the fallbackLifestyle is used. The hybrid lifestyle will
redirect the creation of the instance to the selected lifestyle. By nesting hybrid lifestyles,
any number of lifestyles can be mixed.
| |
CreateHybrid(FuncBoolean, Lifestyle, Lifestyle) |
The hybrid lifestyle allows mixing two lifestyles in a single registration. Based on the supplied
lifestyleSelector delegate the hybrid lifestyle will redirect the creation of
the instance to the correct lifestyle. The result of the lifestyleSelector
delegate will not be cached; it is invoked each time an instance is requested or injected. By
nesting hybrid lifestyles, any number of lifestyles can be mixed.
| |
CreateHybrid(FuncBoolean, ScopedLifestyle, ScopedLifestyle) |
The hybrid lifestyle allows mixing two lifestyles in a single registration. Based on the supplied
lifestyleSelector delegate the hybrid lifestyle will redirect the creation of
the instance to the correct lifestyle. The result of the lifestyleSelector
delegate will not be cached; it is invoked each time an instance is requested or injected. By
nesting hybrid lifestyles, any number of lifestyles can be mixed.
| |
CreateProducer(Type, Type, Container) |
Creates a new InstanceProducer instance for the given serviceType
that will create new instances of specified implementationType with the
caching as specified by this lifestyle.
| |
CreateProducerTService(FuncTService, Container) |
Creates a new InstanceProducer instance for the given TService
that will create new instances instance using the supplied instanceCreator
with the caching as specified by this lifestyle.
| |
CreateProducerTService(Type, Container) |
Creates a new InstanceProducer instance for the given TService
that will create new instances of specified implementationType caching as
specified by this lifestyle.
| |
CreateProducerTService, TImplementation(Container) |
Creates a new InstanceProducer instance for the given TService
that will create new instances of specified TImplementation with the
caching as specified by this lifestyle.
| |
CreateRegistration(Type, Container) |
Creates a new Registration instance defining the creation of the
specified concreteType with the caching as specified by this lifestyle,
or returns an already created Registration instance for this container + lifestyle
+ type combination.
This method might fail when run in a partial trust sandbox when concreteType
is an internal type.
| |
CreateRegistration(Type, FuncObject, Container) |
Creates a new Registration instance defining the creation of the
specified serviceType using the supplied instanceCreator
with the caching as specified by this lifestyle.
| |
CreateRegistrationTConcrete(Container) |
Creates a new Registration instance defining the creation of the
specified TConcrete with the caching as specified by this lifestyle,
or returns an already created Registration instance for this container + lifestyle
+ type combination.
| |
CreateRegistrationTService(FuncTService, Container) |
Creates a new Registration instance defining the creation of the
specified TService using the supplied instanceCreator
with the caching as specified by this lifestyle.
| |
CreateRegistrationCore(Type, Container) |
When overridden in a derived class,
creates a new Registration instance defining the creation of the
specified concreteType with the caching as specified by this lifestyle.
| |
CreateRegistrationCoreTService(FuncTService, Container) |
When overridden in a derived class,
creates a new Registration instance defining the creation of the
specified TService using the supplied instanceCreator
with the caching as specified by this lifestyle.
|
Name | Description | |
---|---|---|
Scoped | The lifestyle that caches components according to the lifetime of the container's configured scoped lifestyle. In case the type of a cached instance implements IDisposable, the container will ensure its disposal when the active scope gets disposed. | |
Singleton | The lifestyle that caches components during the lifetime of the Container instance and guarantees that only a single instance of that component is created for that instance. Since general use is to create a single Container instance for the lifetime of the application / AppDomain, this would mean that only a single instance of that component would exist during the lifetime of the application. In a multi-threaded applications, implementations registered using this lifestyle must be thread-safe. In case the type of a cached instance implements IDisposable, the container will ensure its disposal when the container gets disposed. | |
Transient |
The lifestyle instance that doesn't cache instances. A new instance of the specified
component is created every time the registered service is requested or injected.
|