Terraria v1.4.4.9
Terraria source code documentation
All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Events Macros
ReadOnlyCollection.cs
Go to the documentation of this file.
4
6
9[DebuggerDisplay("Count = {Count}")]
10[TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
12{
13 private readonly IList<T> list;
14
15 public int Count => list.Count;
16
17 public T this[int index] => list[index];
18
19 protected IList<T> Items => list;
20
22
23 T IList<T>.this[int index]
24 {
25 get
26 {
27 return list[index];
28 }
29 set
30 {
31 ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_ReadOnlyCollection);
32 }
33 }
34
35 bool ICollection.IsSynchronized => false;
36
37 object ICollection.SyncRoot
38 {
39 get
40 {
42 {
43 return this;
44 }
45 return collection.SyncRoot;
46 }
47 }
48
49 bool IList.IsFixedSize => true;
50
51 bool IList.IsReadOnly => true;
52
53 object? IList.this[int index]
54 {
55 get
56 {
57 return list[index];
58 }
59 set
60 {
61 ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_ReadOnlyCollection);
62 }
63 }
64
66 {
67 if (list == null)
68 {
70 }
71 this.list = list;
72 }
73
74 public bool Contains(T value)
75 {
76 return list.Contains(value);
77 }
78
79 public void CopyTo(T[] array, int index)
80 {
81 list.CopyTo(array, index);
82 }
83
85 {
86 return list.GetEnumerator();
87 }
88
89 public int IndexOf(T value)
90 {
91 return list.IndexOf(value);
92 }
93
95 {
96 ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_ReadOnlyCollection);
97 }
98
100 {
101 ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_ReadOnlyCollection);
102 }
103
104 void IList<T>.Insert(int index, T value)
105 {
106 ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_ReadOnlyCollection);
107 }
108
110 {
111 ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_ReadOnlyCollection);
112 return false;
113 }
114
115 void IList<T>.RemoveAt(int index)
116 {
117 ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_ReadOnlyCollection);
118 }
119
121 {
122 return ((IEnumerable)list).GetEnumerator();
123 }
124
126 {
127 if (array == null)
128 {
130 }
131 if (array.Rank != 1)
132 {
133 ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_RankMultiDimNotSupported);
134 }
135 if (array.GetLowerBound(0) != 0)
136 {
138 }
139 if (index < 0)
140 {
142 }
143 if (array.Length - index < Count)
144 {
145 ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_ArrayPlusOffTooSmall);
146 }
147 if (array is T[] array2)
148 {
149 list.CopyTo(array2, index);
150 return;
151 }
152 Type elementType = array.GetType().GetElementType();
154 if (!elementType.IsAssignableFrom(typeFromHandle) && !typeFromHandle.IsAssignableFrom(elementType))
155 {
157 }
158 object[] array3 = array as object[];
159 if (array3 == null)
160 {
162 }
163 int count = list.Count;
164 try
165 {
166 for (int i = 0; i < count; i++)
167 {
168 array3[index++] = list[i];
169 }
170 }
172 {
174 }
175 }
176
177 int IList.Add(object value)
178 {
179 ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_ReadOnlyCollection);
180 return -1;
181 }
182
184 {
185 ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_ReadOnlyCollection);
186 }
187
188 private static bool IsCompatibleObject(object value)
189 {
190 if (!(value is T))
191 {
192 if (value == null)
193 {
194 return default(T) == null;
195 }
196 return false;
197 }
198 return true;
199 }
200
201 bool IList.Contains(object value)
202 {
204 {
205 return Contains((T)value);
206 }
207 return false;
208 }
209
210 int IList.IndexOf(object value)
211 {
213 {
214 return IndexOf((T)value);
215 }
216 return -1;
217 }
218
219 void IList.Insert(int index, object value)
220 {
221 ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_ReadOnlyCollection);
222 }
223
224 void IList.Remove(object value)
225 {
226 ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_ReadOnlyCollection);
227 }
228
230 {
231 ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_ReadOnlyCollection);
232 }
233}
bool ICollection< KeyValuePair< TKey, TValue > >. Remove(KeyValuePair< TKey, TValue > keyValuePair)
bool ICollection< KeyValuePair< TKey, TValue > >. IsReadOnly
void Add(TKey key, TValue value)
static void ThrowNotSupportedException(ExceptionResource resource)
static void ThrowArgumentException_Argument_InvalidArrayType()
static void ThrowArgumentNullException(string name)
static void ThrowArgumentException(ExceptionResource resource)
static void ThrowIndexArgumentOutOfRange_NeedNonNegNumException()
static ? Type GetType(string typeName, bool throwOnError, bool ignoreCase)
Definition Type.cs:408
void CopyTo(Array array, int index)
void RemoveAt(int index)
void Insert(int index, object? value)
int Add(object? value)
bool Contains(object? value)
void Remove(object? value)
int IndexOf(object? value)