using System;
using System.Collections.Generic;
using JD.Kernel.StaticHelpers;
namespace JD.Collections.ObjectModel
{
///
/// A read-only implementation of the interface.
/// Methods that modify the collection throw a NotSupportedException, methods that don't
/// modify are forwarded through to the wrapped collection.
///
[Serializable]
public class ReadOnlyCollection : ReadOnlyCollectionBase
{
#region Variables
private readonly ICollection m_wrappedCollection;
#endregion
#region Constructor
///
/// Creates a ReadOnlyCollection wrapped around the given collection.
///
/// Collection to wrap.
public ReadOnlyCollection(ICollection wrappedCollection)
{
Throw.IfNull(wrappedCollection, "wrappedCollection");
m_wrappedCollection = wrappedCollection;
}
#endregion
#region Wrapped members
///
/// Count.
///
public override int Count
{
get { return m_wrappedCollection.Count; }
}
///
/// GetEnumerator.
///
///
public override IEnumerator GetEnumerator()
{
return m_wrappedCollection.GetEnumerator();
}
///
/// Contains.
///
///
///
public override bool Contains(T item)
{
return m_wrappedCollection.Contains(item);
}
///
/// CopyTo.
///
///
///
public override void CopyTo(T[] array, int arrayIndex)
{
m_wrappedCollection.CopyTo(array, arrayIndex);
}
#endregion
}
}