Table of Contents

Method GetOrAddAsync

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

GetOrAddAsync<T>(Func<Task<T>>)

Asynchronously 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 asynchronous getter function.

public Task<T> GetOrAddAsync<T>(Func<Task<T>> getter) where T : notnull

Parameters

getter Func<Task<T>>

An asynchronous function that provides the object to be added if it does not exist.

Returns

Task<T>

A task that represents the asynchronous operation. The task result contains the object of type T from the context bag.

Type Parameters

T

The type of the object defined in this context bag.