Method
TypedValueDictionary.GetOrAdd<T>
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 : notnullParameters #
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.
GetOrAdd<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 by creating a new instance of T.
public T GetOrAdd<T>() where T : notnull, new()Returns #
T
The object of type T from the context bag.
Type Parameters #
T
The type of the object defined in this context bag. It must have a public parameterless constructor.