using System.Collections.Generic; using JD.Collections.Interfaces; using JD.Kernel.StaticHelpers; namespace JD.Collections.ObjectModel { public class ReadOnlyKeyedCollection : ReadOnlyCollectionBase, IKeyedCollection { #region Variables private readonly KeyedCollection m_wrappedCollection; #endregion #region Constructor /// /// Constructor. /// /// public ReadOnlyKeyedCollection(KeyedCollection collection) { Throw.IfNull(collection, "collection"); m_wrappedCollection = collection; } #endregion #region Properties /// /// Count. /// public override int Count { get { return m_wrappedCollection.Count; } } /// /// Indexer. /// /// /// public TValue this[TKey key] { get { return m_wrappedCollection[key]; } } #endregion #region Methods /// /// ContainsKey. /// /// /// public bool ContainsKey(TKey key) { return m_wrappedCollection.ContainsKey(key); } /// /// Remove. /// /// /// public bool Remove(TKey key) { MethodModifiesCollection(); return false; } public bool TryGetValue(TKey key, out TValue value) { return m_wrappedCollection.TryGetValue(key, out value); } /// /// GetEnumerator. /// /// public override IEnumerator GetEnumerator() { return m_wrappedCollection.GetEnumerator(); } #endregion } }