summary refs log tree commit diff
path: root/LibGit/Extensions/DictionaryExtensions.cs
diff options
context:
space:
mode:
authorTheArcaneBrony <myrainbowdash949@gmail.com>2023-06-05 03:25:53 +0200
committerTheArcaneBrony <myrainbowdash949@gmail.com>2023-06-05 03:25:53 +0200
commit51d820e22a4517dbb06d38a4f07f7c48522ef811 (patch)
tree4a7749cf77223dff2414fd4b73cb17df43d7449e /LibGit/Extensions/DictionaryExtensions.cs
downloadGitTools-master.tar.xz
Initial commit HEAD master
Diffstat (limited to 'LibGit/Extensions/DictionaryExtensions.cs')
-rw-r--r--LibGit/Extensions/DictionaryExtensions.cs15
1 files changed, 15 insertions, 0 deletions
diff --git a/LibGit/Extensions/DictionaryExtensions.cs b/LibGit/Extensions/DictionaryExtensions.cs
new file mode 100644

index 0000000..0e6df06 --- /dev/null +++ b/LibGit/Extensions/DictionaryExtensions.cs
@@ -0,0 +1,15 @@ +namespace LibGit.Extensions; + +public static class DictionaryExtensions +{ + public static bool ChangeKey<TKey, TValue>(this IDictionary<TKey, TValue> dict, + TKey oldKey, TKey newKey) + { + TValue value; + if (!dict.Remove(oldKey, out value)) + return false; + + dict[newKey] = value; // or dict.Add(newKey, value) depending on ur comfort + return true; + } +} \ No newline at end of file