From 18462beb3132c7c37cd2a695a14855e359be139b Mon Sep 17 00:00:00 2001 From: Martin Evans Date: Thu, 20 Jul 2023 16:41:19 +0100 Subject: [PATCH] - Removed the `Update` and `GetOrDefault` extension methods (they were unused). - Renamed `DictionaryExtensions` to `KeyValuePairExtensions`, since nothing in that file extends dictionary any more! --- LLama/Extensions/DictionaryExtensions.cs | 30 ---------------------- LLama/Extensions/KeyValuePairExtensions.cs | 24 +++++++++++++++++ 2 files changed, 24 insertions(+), 30 deletions(-) delete mode 100644 LLama/Extensions/DictionaryExtensions.cs create mode 100644 LLama/Extensions/KeyValuePairExtensions.cs diff --git a/LLama/Extensions/DictionaryExtensions.cs b/LLama/Extensions/DictionaryExtensions.cs deleted file mode 100644 index 286a97ddb..000000000 --- a/LLama/Extensions/DictionaryExtensions.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace LLama.Extensions -{ - public static class DictionaryExtension - { - public static void Deconstruct(this KeyValuePair pair, out T1 first, out T2 second) - { - first = pair.Key; - second = pair.Value; - } - public static void Update(this Dictionary dic, IDictionary other) - { - foreach (var (key, value) in other) - { - dic[key] = value; - } - } - public static T2 GetOrDefault(this Dictionary dic, T1 key, T2 defaultValue) - { - if (dic.ContainsKey(key)) - { - return dic[key]; - } - return defaultValue; - } - } -} diff --git a/LLama/Extensions/KeyValuePairExtensions.cs b/LLama/Extensions/KeyValuePairExtensions.cs new file mode 100644 index 000000000..814e0a131 --- /dev/null +++ b/LLama/Extensions/KeyValuePairExtensions.cs @@ -0,0 +1,24 @@ +using System.Collections.Generic; + +namespace LLama.Extensions +{ + /// + /// Extensions to the KeyValuePair struct + /// + public static class KeyValuePairExtensions + { + /// + /// Deconstruct a KeyValuePair into it's constituent parts. + /// + /// The KeyValuePair to deconstruct + /// First element, the Key + /// Second element, the Value + /// Type of the Key + /// Type of the Value + public static void Deconstruct(this KeyValuePair pair, out TKey first, out TValue second) + { + first = pair.Key; + second = pair.Value; + } + } +}