diff options
author | TheArcaneBrony <myrainbowdash949@gmail.com> | 2023-05-28 11:30:53 +0200 |
---|---|---|
committer | TheArcaneBrony <myrainbowdash949@gmail.com> | 2023-05-28 11:30:53 +0200 |
commit | a357bec1831611758a19bf23ff0fa5a5fe99ca52 (patch) | |
tree | 2aa839591e39fdfd9e94a4f1c75fe93b94b246d5 /MatrixRoomUtils.Core/Extensions | |
parent | Remove a bunch of caching, make room listings more reliable (diff) | |
download | MatrixUtils-a357bec1831611758a19bf23ff0fa5a5fe99ca52.tar.xz |
Add changes
Diffstat (limited to 'MatrixRoomUtils.Core/Extensions')
-rw-r--r-- | MatrixRoomUtils.Core/Extensions/DictionaryExtensions.cs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/MatrixRoomUtils.Core/Extensions/DictionaryExtensions.cs b/MatrixRoomUtils.Core/Extensions/DictionaryExtensions.cs new file mode 100644 index 0000000..cce71dd --- /dev/null +++ b/MatrixRoomUtils.Core/Extensions/DictionaryExtensions.cs @@ -0,0 +1,15 @@ +namespace MatrixRoomUtils.Core.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 |