ContainerOptionsUseLoosenedLifestyleMismatchBehavior Property

Simple Injector

Note: This API is now obsolete.

Gets or sets a value indicating whether the container should use a loosened (i.e. less strict) behavior for detecting lifestyle mismatches (see: In short, when UseLoosenedLifestyleMismatchBehavior is set to trueTransient dependencies are allowed to be injected into Scoped components. When disabled, a warning would be given in that case. The default value is true.

Simple Injector allows custom lifestyles to be created and this loosened behavior works on custom lifestyles as well. The loosened behavior will ignore any lifestyle mismatch checks on any component with a lifestyle that has a Length that is equal or shorter than the length of Scoped.

Namespace:  SimpleInjector
Assembly:  SimpleInjector (in SimpleInjector.dll) Version: 5.3.0

[ObsoleteAttribute("Please use the UseStrictLifestyleMismatchBehavior property instead. Note that UseStrictLifestyleMismatchBehavior's behavior is negated. This means that if you're currently supplying 'false' to UseLoosenedLifestyleMismatchBehavior, you will have to supply 'true' to UseStrictLifestyleMismatchBehavior instead, and vise versa. Also note that 'loosend' behavior became the default in 5.0 — In case you are assinging UseLoosenedLifestyleMismatchBehavior to 'true', the call can be removed safely. Will be treated as an error from version 5.5. Will be removed in version 6.0.", 
public bool UseLoosenedLifestyleMismatchBehavior { get; set; }

Property Value

Type: Boolean
The value indicating whether the container uses loosened or strict behavior when validating mismatches on Scoped components.
See Also