You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
85 lines
2.1 KiB
85 lines
2.1 KiB
// Needed for NET40 |
|
#if !NET_4_6 |
|
using System; |
|
using System.Collections; |
|
using System.Collections.Generic; |
|
|
|
namespace LinqInternal.Collections.Specialized |
|
{ |
|
[Serializable] |
|
internal sealed class KeyCollection<TKey, TValue> : ICollection<TKey>, ICollection, IReadOnlyCollection<TKey> |
|
{ |
|
private readonly IDictionary<TKey, TValue> _wrapped; |
|
|
|
internal KeyCollection(IDictionary<TKey, TValue> 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<TKey>.IsReadOnly |
|
{ |
|
get { return true; } |
|
} |
|
|
|
public void CopyTo(TKey[] array, int arrayIndex) |
|
{ |
|
Extensions.CanCopyTo(_wrapped.Count, array, arrayIndex); |
|
_wrapped.ConvertProgressive(pair => pair.Key).CopyTo(array, arrayIndex); |
|
} |
|
|
|
public IEnumerator<TKey> GetEnumerator() |
|
{ |
|
return _wrapped.ConvertProgressive(pair => pair.Key).GetEnumerator(); |
|
} |
|
|
|
void ICollection.CopyTo(Array array, int index) |
|
{ |
|
((ICollection)_wrapped).CopyTo(array, index); |
|
} |
|
|
|
void ICollection<TKey>.Add(TKey item) |
|
{ |
|
throw new NotSupportedException(); |
|
} |
|
|
|
void ICollection<TKey>.Clear() |
|
{ |
|
throw new NotSupportedException(); |
|
} |
|
|
|
bool ICollection<TKey>.Contains(TKey item) |
|
{ |
|
return _wrapped.ContainsKey(item); |
|
} |
|
|
|
bool ICollection<TKey>.Remove(TKey item) |
|
{ |
|
throw new NotSupportedException(); |
|
} |
|
|
|
IEnumerator IEnumerable.GetEnumerator() |
|
{ |
|
return GetEnumerator(); |
|
} |
|
} |
|
} |
|
#endif |