// Needed for NET40 #if !NET_4_6 using System; using System.Collections; using System.Collections.Generic; using System.Linq; namespace LinqInternal.Collections.Specialized { [Serializable] internal sealed class ValueCollection : ICollection, ICollection, IReadOnlyCollection { private readonly IDictionary _wrapped; internal ValueCollection(IDictionary wrapped) { if (wrapped == null) { throw new ArgumentNullException("wrapped"); } _wrapped = wrapped; } public int Count { get { return _wrapped.Count; } } bool ICollection.IsSynchronized { get { return ((ICollection)_wrapped).IsSynchronized; } } object ICollection.SyncRoot { get { return ((ICollection)_wrapped).SyncRoot; } } bool ICollection.IsReadOnly { get { return true; } } public void CopyTo(TValue[] array, int arrayIndex) { Extensions.CanCopyTo(_wrapped.Count, array, arrayIndex); _wrapped.ConvertProgressive(pair => pair.Value).CopyTo(array, arrayIndex); } public IEnumerator GetEnumerator() { return _wrapped.ConvertProgressive(pair => pair.Value).GetEnumerator(); } void ICollection.CopyTo(Array array, int index) { ((ICollection)_wrapped).CopyTo(array, index); } void ICollection.Add(TValue item) { throw new NotSupportedException(); } void ICollection.Clear() { throw new NotSupportedException(); } bool ICollection.Contains(TValue item) { return _wrapped.Where(pair => EqualityComparer.Default.Equals(item, pair.Value)).HasAtLeast(1); } bool ICollection.Remove(TValue item) { throw new NotSupportedException(); } IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); } } } #endif