Sisk

Method

TypedValueDictionary.GetOrAdd<T>

Namespace
Sisk.Core.Entity
Assembly
Sisk.Core.dll

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.

C#
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.

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.

C#
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.

Type to search the documentation and the API reference.