using System; using System.Collections; using System.Collections.Generic; using System.Linq; namespace OpenTap { class EmptyDictionary : IDictionary { private EmptyDictionary() { } public static EmptyDictionary Instance { get; } = new EmptyDictionary(); public IEnumerator> GetEnumerator() => Enumerable.Empty>().GetEnumerator(); IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); public void Add(KeyValuePair item) => throw new NotSupportedException(); public void Clear() { } public bool Contains(KeyValuePair item) => false; public void CopyTo(KeyValuePair[] array, int arrayIndex) { } public bool Remove(KeyValuePair item) => false; public int Count => 0; public bool IsReadOnly => true; public void Add(K key, V value) => throw new NotSupportedException(); public bool ContainsKey(K key) => false; public bool Remove(K key) => false; public bool TryGetValue(K key, out V value) { value = default; return false; } public V this[K key] { get => throw new KeyNotFoundException(); set => throw new NotSupportedException(); } public ICollection Keys => Array.Empty(); public ICollection Values => Array.Empty(); } }