namespace System.Collections.Generic; public static class DictionaryExtensions { public static T GetOrAddCustomConfiguration(this IDictionary customConfiguration, string key) where T : new() { if (customConfiguration.TryGetValue(key, out var config)) return (T)config; var newInstance = new T(); customConfiguration[key] = newInstance; return newInstance; } public static void Deconstruct(this KeyValuePair pair, out TKey key, out TValue value) { key = pair.Key; value = pair.Value; } }