Method GetOrAdd
GetOrAdd<T>(Func<T>)
Gets a singleton previously defined in this context bag via its type T
.
If it does not exist, it adds the object to the context bag using the provided getter
function.
public T GetOrAdd<T>(Func<T> getter) where T : notnull
Parameters
getter
Func<T>A function that provides the object to be added if it does not exist.
Returns
- T
The object of type
T
from the context bag.
Type Parameters
T
The type of the object defined in this context bag.