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
Assembly: SimpleInjector (in SimpleInjector.dll) Version: 5.3.0
Syntax
Parameters
- 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: TThe stored item or the item from the valueFactory.
Exceptions
Exception | Condition |
---|---|
ArgumentNullException | Thrown when either of the arguments is a null reference. |
See Also