public static TValue SafeGet <TKey, TValue>(this IReadOnlyDictionary <TKey, TValue> dictionary, TKey key) { dictionary.ArgumentNotNull(nameof(dictionary)); return(dictionary.TryGetValue(key, out var value) ? value : default(TValue)); }