AdvancedExtensionsGetOrSetItemT Method

Simple Injector

Note: This API is now obsolete.

Adds an item by the given key in the container by using the specified function, if the key does not already exist. This operation is atomic.

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

[ObsoleteAttribute("Please use Container.ContainerScope.GetOrSetItem instead. Will be removed in version 6.0.", 
	true)]
[EditorBrowsableAttribute(EditorBrowsableState.Never)]
public static T GetOrSetItem<T>(
	this Container container,
	Object key,
	Func<Container, Object, T> valueFactory
)

Parameters

container
Type: SimpleInjectorContainer
The container.
key
Type: SystemObject
The key of the item to insert or override.
valueFactory
Type: SystemFuncContainer, Object, T
The function used to generate a value for the given key. The supplied value of key will be supplied to the function when called.

Type Parameters

T
The Type of the item to create.

Return Value

Type: T
The stored item or the item from the valueFactory.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type Container. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).
Exceptions

ExceptionCondition
ArgumentNullExceptionThrown when either container, key or valueFactory is a null reference.
See Also

Reference