// Copyright © WireMock.Net namespace System.Collections.Generic; internal static class DictionaryExtensions { #if NETSTANDARD2_0 public static bool TryAdd(this Dictionary? dictionary, TKey key, TValue value) { if (dictionary is null || dictionary.ContainsKey(key)) { return false; } dictionary[key] = value; return true; } #endif public static bool TryGetFirstValue(this IDictionary? dictionary, out TValue? value) { if (dictionary != null && dictionary.Count > 0) { value = dictionary.First().Value; return true; } value = default; return false; } public static bool TryGetFirstOrDefault(this IDictionary? dictionary, out KeyValuePair value) { if (dictionary != null && dictionary.Count > 0) { value = dictionary.First(); return true; } value = default; return false; } }