diff --git a/Masuit.Tools.Core/Extensions.cs b/Masuit.Tools.Core/Extensions.cs index 6b4c9cb4..39ecee49 100644 --- a/Masuit.Tools.Core/Extensions.cs +++ b/Masuit.Tools.Core/Extensions.cs @@ -1280,9 +1280,14 @@ public static TValue AddOrUpdate(this IDictionary @t public static TValue AddOrUpdate(this IDictionary @this, TKey key, Func addValueFactory, Func updateValueFactory) { if (!@this.ContainsKey(key)) + { @this.Add(new KeyValuePair(key, addValueFactory(key))); + } else + { @this[key] = updateValueFactory(key, @this[key]); + } + return @this[key]; } diff --git a/Masuit.Tools/Extensions.cs b/Masuit.Tools/Extensions.cs index 4d946dab..e1f3df39 100644 --- a/Masuit.Tools/Extensions.cs +++ b/Masuit.Tools/Extensions.cs @@ -1278,9 +1278,14 @@ public static TValue AddOrUpdate(this IDictionary @t public static TValue AddOrUpdate(this IDictionary @this, TKey key, Func addValueFactory, Func updateValueFactory) { if (!@this.ContainsKey(key)) + { @this.Add(new KeyValuePair(key, addValueFactory(key))); + } else + { @this[key] = updateValueFactory(key, @this[key]); + } + return @this[key]; }