#if FAT using System; using System.Collections.Generic; using LinqInternal.Collections.Specialized; using LinqInternal.Core; namespace LinqInternal.Collections { [Serializable] [System.Diagnostics.DebuggerNonUserCode] internal sealed class ExtendedReadOnlyDictionary : IReadOnlyCollection>, IReadOnlyDictionary, IExtendedDictionary { private readonly ExtendedReadOnlyCollection _keys; private readonly ExtendedReadOnlyCollection _values; private readonly IDictionary _wrapped; public ExtendedReadOnlyDictionary(IDictionary dictionary) { if (dictionary == null) { throw new ArgumentNullException("dictionary"); } _wrapped = dictionary; _keys = new ExtendedReadOnlyCollection(new DelegatedCollection(() => _wrapped.Keys)); _values = new ExtendedReadOnlyCollection(new DelegatedCollection(() => _wrapped.Values)); } public int Count { get { return _wrapped.Count; } } bool ICollection>.IsReadOnly { get { return true; } } ICollection IDictionary.Keys { get { return _keys; } } ICollection IDictionary.Values { get { return _values; } } IReadOnlyCollection> IExtendedCollection>.AsReadOnly { get { return this; } } IReadOnlyDictionary IExtendedDictionary.AsReadOnly { get { return this; } } IEnumerable IReadOnlyDictionary.Keys { get { return _keys; } } IEnumerable IReadOnlyDictionary.Values { get { return _values; } } public IReadOnlyCollection Keys { get { return _keys; } } public IReadOnlyCollection Values { get { return _values; } } TValue IDictionary.this[TKey key] { get { return this[key]; } set { throw new NotSupportedException(); } } public TValue this[TKey key] { get { return _wrapped[key]; } } public bool Contains(KeyValuePair item) { return _wrapped.Contains(item); } public bool Contains(KeyValuePair item, IEqualityComparer> comparer) { return System.Linq.Enumerable.Contains(this, item, comparer); } public bool ContainsKey(TKey key) { return _wrapped.ContainsKey(key); } public void CopyTo(KeyValuePair[] array, int arrayIndex) { _wrapped.CopyTo(array, arrayIndex); } public void CopyTo(KeyValuePair[] array) { _wrapped.CopyTo(array, 0); } public void CopyTo(KeyValuePair[] array, int arrayIndex, int countLimit) { Extensions.CanCopyTo(array, arrayIndex, countLimit); Extensions.CopyTo(this, array, arrayIndex, countLimit); } public IEnumerator> GetEnumerator() { return _wrapped.GetEnumerator(); } void ICollection>.Add(KeyValuePair item) { throw new NotSupportedException(); } void ICollection>.Clear() { throw new NotSupportedException(); } bool ICollection>.Remove(KeyValuePair item) { throw new NotSupportedException(); } void IDictionary.Add(TKey key, TValue value) { throw new NotSupportedException(); } bool IDictionary.Remove(TKey key) { throw new NotSupportedException(); } bool IExtendedCollection>.Remove(KeyValuePair item, IEqualityComparer> comparer) { throw new NotSupportedException(); } public bool IsProperSubsetOf(IEnumerable> other) { return Extensions.IsProperSubsetOf(this, other); } public bool IsProperSupersetOf(IEnumerable> other) { return Extensions.IsProperSupersetOf(this, other); } public bool IsSubsetOf(IEnumerable> other) { return Extensions.IsSubsetOf(this, other); } public bool IsSupersetOf(IEnumerable> other) { return Extensions.IsSupersetOf(this, other); } public bool Overlaps(IEnumerable> other) { return Extensions.Overlaps(this, other); } public bool SetEquals(IEnumerable> other) { return Extensions.SetEquals(this, other); } System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { return GetEnumerator(); } public KeyValuePair[] ToArray() { var array = new KeyValuePair[_wrapped.Count]; CopyTo(array); return array; } public bool TryGetValue(TKey key, out TValue value) { return _wrapped.TryGetValue(key, out value); } } } #endif