diff --git a/framework/src/Volo.Abp.Core/System/Collections/Generic/AbpDictionaryExtensions.cs b/framework/src/Volo.Abp.Core/System/Collections/Generic/AbpDictionaryExtensions.cs
index 2d2ae9d6dc..148b34fa90 100644
--- a/framework/src/Volo.Abp.Core/System/Collections/Generic/AbpDictionaryExtensions.cs
+++ b/framework/src/Volo.Abp.Core/System/Collections/Generic/AbpDictionaryExtensions.cs
@@ -67,7 +67,7 @@ namespace System.Collections.Generic
{
return dictionary.TryGetValue(key, out var obj) ? obj : default;
}
-
+
///
/// Gets a value from the dictionary with given key. Returns default value if can not find.
///
@@ -100,7 +100,7 @@ namespace System.Collections.Generic
return dictionary[key] = factory(key);
}
-
+
///
/// Gets a value from the dictionary with given key. Returns default value if can not find.
///
@@ -114,5 +114,19 @@ namespace System.Collections.Generic
{
return dictionary.GetOrAdd(key, k => factory());
}
+
+ ///
+ /// Gets a value from the concurrent dictionary with given key. Returns default value if can not find.
+ ///
+ /// Concurrent dictionary to check and get
+ /// Key to find the value
+ /// A factory method used to create the value if not found in the dictionary
+ /// Type of the key
+ /// Type of the value
+ /// Value if found, default if can not found.
+ public static TValue GetOrAdd(this ConcurrentDictionary dictionary, TKey key, Func factory)
+ {
+ return dictionary.GetOrAdd(key, k => factory());
+ }
}
-}
\ No newline at end of file
+}