/
StringCollection.cs
262 lines (227 loc) · 7.09 KB
/
StringCollection.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
namespace System.Collections.Specialized
{
/// <devdoc>
/// <para>Represents a collection of strings.</para>
/// </devdoc>
[Serializable]
[System.Runtime.CompilerServices.TypeForwardedFrom("System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
public class StringCollection : IList
{
private readonly ArrayList data = new ArrayList(); // Do not rename (binary serialization)
/// <devdoc>
/// <para>Represents the entry at the specified index of the <see cref='System.Collections.Specialized.StringCollection'/>.</para>
/// </devdoc>
public string? this[int index]
{
get
{
return ((string?)data[index]);
}
set
{
data[index] = value;
}
}
/// <devdoc>
/// <para>Gets the number of strings in the
/// <see cref='System.Collections.Specialized.StringCollection'/> .</para>
/// </devdoc>
public int Count
{
get
{
return data.Count;
}
}
bool IList.IsReadOnly
{
get
{
return false;
}
}
bool IList.IsFixedSize
{
get
{
return false;
}
}
/// <devdoc>
/// <para>Adds a string with the specified value to the
/// <see cref='System.Collections.Specialized.StringCollection'/> .</para>
/// </devdoc>
public int Add(string? value)
{
return data.Add(value);
}
/// <devdoc>
/// <para>Copies the elements of a string array to the end of the <see cref='System.Collections.Specialized.StringCollection'/>.</para>
/// </devdoc>
public void AddRange(string[] value)
{
ArgumentNullException.ThrowIfNull(value);
data.AddRange(value);
}
/// <devdoc>
/// <para>Removes all the strings from the
/// <see cref='System.Collections.Specialized.StringCollection'/> .</para>
/// </devdoc>
public void Clear()
{
data.Clear();
}
/// <devdoc>
/// <para>Gets a value indicating whether the
/// <see cref='System.Collections.Specialized.StringCollection'/> contains a string with the specified
/// value.</para>
/// </devdoc>
public bool Contains(string? value)
{
return data.Contains(value);
}
/// <devdoc>
/// <para>Copies the <see cref='System.Collections.Specialized.StringCollection'/> values to a one-dimensional <see cref='System.Array'/> instance at the
/// specified index.</para>
/// </devdoc>
public void CopyTo(string[] array, int index)
{
data.CopyTo(array, index);
}
/// <devdoc>
/// <para>Returns an enumerator that can iterate through
/// the <see cref='System.Collections.Specialized.StringCollection'/> .</para>
/// </devdoc>
public StringEnumerator GetEnumerator()
{
return new StringEnumerator(this);
}
/// <devdoc>
/// <para>Returns the index of the first occurrence of a string in
/// the <see cref='System.Collections.Specialized.StringCollection'/> .</para>
/// </devdoc>
public int IndexOf(string? value)
{
return data.IndexOf(value);
}
/// <devdoc>
/// <para>Inserts a string into the <see cref='System.Collections.Specialized.StringCollection'/> at the specified
/// index.</para>
/// </devdoc>
public void Insert(int index, string? value)
{
data.Insert(index, value);
}
/// <devdoc>
/// <para>Gets a value indicating whether the <see cref='System.Collections.Specialized.StringCollection'/> is read-only.</para>
/// </devdoc>
public bool IsReadOnly
{
get
{
return false;
}
}
/// <devdoc>
/// <para>Gets a value indicating whether access to the
/// <see cref='System.Collections.Specialized.StringCollection'/>
/// is synchronized (thread-safe).</para>
/// </devdoc>
public bool IsSynchronized
{
get
{
return false;
}
}
/// <devdoc>
/// <para> Removes a specific string from the
/// <see cref='System.Collections.Specialized.StringCollection'/> .</para>
/// </devdoc>
public void Remove(string? value)
{
data.Remove(value);
}
/// <devdoc>
/// <para>Removes the string at the specified index of the <see cref='System.Collections.Specialized.StringCollection'/>.</para>
/// </devdoc>
public void RemoveAt(int index)
{
data.RemoveAt(index);
}
/// <devdoc>
/// <para>Gets an object that can be used to synchronize access to the <see cref='System.Collections.Specialized.StringCollection'/>.</para>
/// </devdoc>
public object SyncRoot
{
get
{
return data.SyncRoot;
}
}
object? IList.this[int index]
{
get
{
return this[index];
}
set
{
this[index] = (string?)value;
}
}
int IList.Add(object? value)
{
return Add((string?)value);
}
bool IList.Contains(object? value)
{
return Contains((string?)value);
}
int IList.IndexOf(object? value)
{
return IndexOf((string?)value);
}
void IList.Insert(int index, object? value)
{
Insert(index, (string?)value);
}
void IList.Remove(object? value)
{
Remove((string?)value);
}
void ICollection.CopyTo(Array array, int index)
{
data.CopyTo(array, index);
}
IEnumerator IEnumerable.GetEnumerator()
{
return data.GetEnumerator();
}
}
public class StringEnumerator
{
private readonly System.Collections.IEnumerator _baseEnumerator;
internal StringEnumerator(StringCollection mappings)
{
_baseEnumerator = ((IEnumerable)mappings).GetEnumerator();
}
public string? Current
{
get
{
return (string?)(_baseEnumerator.Current);
}
}
public bool MoveNext()
{
return _baseEnumerator.MoveNext();
}
public void Reset()
{
_baseEnumerator.Reset();
}
}
}