Esempio n. 1
0
 /// <summary>
 ///    Tries to add a value associated to the <paramref name="key"/> if it doesn't exist.
 /// </summary>
 public static Task <TValue> AddOrGet <TKey, TValue>(
     this IStorage <TKey, TValue> storage,
     TKey key,
     TValue value,
     CancellationToken token = default) =>
 storage.AddOrGet(key, _ => Task.FromResult(value), token);
Esempio n. 2
0
 /// <summary>
 ///    Tries to add a value associated to the <paramref name="key"/> if it doesn't exist.
 /// </summary>
 public static Task <TValue> AddOrGet <TKey, TValue>(
     this IStorage <TKey, TValue> storage,
     TKey key,
     Func <TKey, TValue> addFactory) =>
 storage.AddOrGet(key, x => Task.FromResult(addFactory(x)));