using System.Collections.Generic; namespace WingsEmu.Core.Extensions; public static class DictionaryExtension { public static TValue GetOrDefault(this IDictionary dictionary, TKey key, TValue defaultValue = default) => dictionary.TryGetValue(key, out TValue value) ? value : defaultValue; public static TValue GetOrSetDefault(this IDictionary dictionary, TKey key, TValue defaultValue = default) { if (dictionary.TryGetValue(key, out TValue value)) { return value; } dictionary[key] = defaultValue; return defaultValue; } }