ScriptStack 1.0.4
Loading...
Searching...
No Matches
ReadOnlyICollection.cs
Go to the documentation of this file.
1using System;
2using System.Collections;
3using System.Collections.Generic;
4using System.Text;
5
7{
8
9 [Serializable]
10 public class ReadOnlyICollection<T> : ICollection<T>
11 {
12 #region Private Variables
13
14 private ICollection<T> m_collection;
15
16 #endregion
17
18 #region Default Methods
19
26 IEnumerator IEnumerable.GetEnumerator()
27 {
28 return m_collection.GetEnumerator();
29 }
30
31 #endregion
32
33 #region Public Static Methods
34
40 public static ReadOnlyICollection<T> AsReadOnly(ICollection<T> collectionToWrap)
41 {
42 return new ReadOnlyICollection<T>(collectionToWrap);
43 }
44
45 #endregion
46
47 #region Public Methods
48
53 public ReadOnlyICollection(ICollection<T> collectionToWrap)
54 {
55 m_collection = collectionToWrap;
56 }
57
63 public void Add(T item)
64 {
65 }
66
71 public void Clear()
72 {
73 }
74
82 public bool Contains(T item)
83 {
84 return m_collection.Contains(item);
85 }
86
95 public void CopyTo(T[] array, int arrayIndex)
96 {
97 m_collection.CopyTo(array, arrayIndex);
98 }
99
105 public bool IsReadOnly
106 {
107 get
108 {
109 return true;
110 }
111 }
112
121 public bool Remove(T item)
122 {
123 return false;
124 }
125
132 public IEnumerator<T> GetEnumerator()
133 {
134 return m_collection.GetEnumerator();
135 }
136
137 #endregion
138
139 #region Public Properties
140
146 public int Count
147 {
148 get
149 {
150 return m_collection.Count;
151 }
152 }
153
154 #endregion
155 }
156}
int Count
Returns an enumerator that iterates through the collection.
ReadOnlyICollection(ICollection< T > collectionToWrap)
Initializes a new instance of the ReadOnlyICollection<T> class.
bool IsReadOnly
Clear does not change a ReadOnlyICollection.
void Add(T item)
Add does not change a ReadOnlyICollection.
bool Remove(T item)
Remove does not change a ReadOnlyICollection.
static ReadOnlyICollection< T > AsReadOnly(ICollection< T > collectionToWrap)
Returned a read only wrapper around the collectionToWrap.