Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
CollectionBase.cs
Go to the documentation of this file.
1namespace System.Collections;
2
3public abstract class CollectionBase : IList, ICollection, IEnumerable
4{
5 private readonly ArrayList _list;
6
7 protected ArrayList InnerList => _list;
8
9 protected IList List => this;
10
11 public int Capacity
12 {
13 get
14 {
15 return InnerList.Capacity;
16 }
17 set
18 {
19 InnerList.Capacity = value;
20 }
21 }
22
23 public int Count => _list.Count;
24
25 bool IList.IsReadOnly => InnerList.IsReadOnly;
26
27 bool IList.IsFixedSize => InnerList.IsFixedSize;
28
29 bool ICollection.IsSynchronized => InnerList.IsSynchronized;
30
31 object ICollection.SyncRoot => InnerList.SyncRoot;
32
33 object? IList.this[int index]
34 {
35 get
36 {
37 if (index < 0 || index >= Count)
38 {
40 }
41 return InnerList[index];
42 }
43 set
44 {
45 if (index < 0 || index >= Count)
46 {
48 }
50 object obj = InnerList[index];
53 try
54 {
56 }
57 catch
58 {
60 throw;
61 }
62 }
63 }
64
65 protected CollectionBase()
66 {
67 _list = new ArrayList();
68 }
69
70 protected CollectionBase(int capacity)
71 {
73 }
74
75 public void Clear()
76 {
77 OnClear();
80 }
81
82 public void RemoveAt(int index)
83 {
84 if (index < 0 || index >= Count)
85 {
87 }
88 object value = InnerList[index];
92 try
93 {
95 }
96 catch
97 {
99 throw;
100 }
101 }
102
107
108 bool IList.Contains(object value)
109 {
110 return InnerList.Contains(value);
111 }
112
113 int IList.Add(object value)
114 {
117 int num = InnerList.Add(value);
118 try
119 {
121 return num;
122 }
123 catch
124 {
125 InnerList.RemoveAt(num);
126 throw;
127 }
128 }
129
130 void IList.Remove(object value)
131 {
133 int num = InnerList.IndexOf(value);
134 if (num < 0)
135 {
137 }
138 OnRemove(num, value);
139 InnerList.RemoveAt(num);
140 try
141 {
143 }
144 catch
145 {
146 InnerList.Insert(num, value);
147 throw;
148 }
149 }
150
151 int IList.IndexOf(object value)
152 {
153 return InnerList.IndexOf(value);
154 }
155
156 void IList.Insert(int index, object value)
157 {
158 if (index < 0 || index > Count)
159 {
161 }
165 try
166 {
168 }
169 catch
170 {
172 throw;
173 }
174 }
175
177 {
178 return InnerList.GetEnumerator();
179 }
180
181 protected virtual void OnSet(int index, object? oldValue, object? newValue)
182 {
183 }
184
185 protected virtual void OnInsert(int index, object? value)
186 {
187 }
188
189 protected virtual void OnClear()
190 {
191 }
192
193 protected virtual void OnRemove(int index, object? value)
194 {
195 }
196
197 protected virtual void OnValidate(object value)
198 {
199 if (value == null)
200 {
201 throw new ArgumentNullException("value");
202 }
203 }
204
205 protected virtual void OnSetComplete(int index, object? oldValue, object? newValue)
206 {
207 }
208
209 protected virtual void OnInsertComplete(int index, object? value)
210 {
211 }
212
213 protected virtual void OnClearComplete()
214 {
215 }
216
217 protected virtual void OnRemoveComplete(int index, object? value)
218 {
219 }
220}
virtual IEnumerator GetEnumerator()
virtual int Add(object? value)
virtual void RemoveAt(int index)
virtual bool Contains(object? item)
virtual void CopyTo(Array array)
virtual void Insert(int index, object? value)
virtual int IndexOf(object? value)
virtual void OnValidate(object value)
virtual void OnInsertComplete(int index, object? value)
virtual void OnInsert(int index, object? value)
virtual void OnRemoveComplete(int index, object? value)
virtual void OnSet(int index, object? oldValue, object? newValue)
virtual void OnRemove(int index, object? value)
virtual void OnSetComplete(int index, object? oldValue, object? newValue)
static string ArgumentOutOfRange_Index
Definition SR.cs:30
static string Arg_RemoveArgNotFound
Definition SR.cs:20
Definition SR.cs:7
void CopyTo(Array array, int index)
void Insert(int index, object? value)
int Add(object? value)
bool Contains(object? value)
void Remove(object? value)
int IndexOf(object? value)