ConcurrentDictionaryExtensions
using System.Runtime.CompilerServices;
namespace System.Collections.Concurrent
{
internal static class ConcurrentDictionaryExtensions
{
[System.Runtime.CompilerServices.NullableContext(1)]
public static TValue GetOrAdd<[System.Runtime.CompilerServices.Nullable(2)] TKey, [System.Runtime.CompilerServices.Nullable(2)] TValue, [System.Runtime.CompilerServices.Nullable(2)] TArg>(this ConcurrentDictionary<TKey, TValue> dictionary, TKey key, Func<TKey, TArg, TValue> valueFactory, TArg factoryArgument)
{
if (dictionary.TryGetValue(key, out TValue value))
return value;
return dictionary.GetOrAdd(key, valueFactory(key, factoryArgument));
}
}
}