/
dev-npgsql
/
npgsql
Обзор
Документация
Войти
/
dev-npgsql
/
npgsql
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
v8.0.7
src/Npgsql/Shims/ConcurrentDictionaryExtensions.cs
15 строк
804 B
Nino Floris
Handler rework (#5123)
26 сен 2023, 00:08
Не верифицирован
26 сен 2023, 00:08
0b7aecb
Код
Авторство
О чём код?
namespace System.Collections.Concurrent; #if NETSTANDARD2_0 static class ConcurrentDictionaryExtensions { public static TValue GetOrAdd<TKey, TValue, TArg>(this ConcurrentDictionary<TKey, TValue> instance, TKey key, Func<TKey, TArg, TValue> valueFactory, TArg factoryArgument) { // The actual closure capture exists in a local function to prevent a display class allocation at the start of the method. return instance.TryGetValue(key, out var value) ? value : GetOrAddWithClosure(instance, key, valueFactory, factoryArgument); static TValue GetOrAddWithClosure(ConcurrentDictionary<TKey, TValue> instance, TKey key, Func<TKey, TArg, TValue> valuefactory, TArg factoryargument) => instance.GetOrAdd(key, key => valuefactory(key, factoryargument)); } } #endif