namespace System.Collections.Generic; public static class AdjudicationDictionaryExtensions { /// /// Create and add a value to a dictionary only if the key is not already present. /// /// The dictionary to check for the key. /// The key to check and use if it isn't already present. /// A function that returns the value to insert if the key is not present. public static void Ensure( this IDictionary dictionary, TKey key, Func valueFunc) { if (!dictionary.ContainsKey(key)) { dictionary[key] = valueFunc(); } } }