Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
DataColumnMappingCollection.cs
Go to the documentation of this file.
6
7namespace System.Data.Common;
8
10{
12
13 bool ICollection.IsSynchronized => false;
14
15 object ICollection.SyncRoot => this;
16
17 bool IList.IsReadOnly => false;
18
19 bool IList.IsFixedSize => false;
20
21 object? IList.this[int index]
22 {
23 get
24 {
25 return this[index];
26 }
27 set
28 {
31 }
32 }
33
34 object IColumnMappingCollection.this[string index]
35 {
36 get
37 {
38 return this[index];
39 }
40 set
41 {
44 }
45 }
46
47 [Browsable(false)]
49 public int Count
50 {
51 get
52 {
53 if (_items == null)
54 {
55 return 0;
56 }
57 return _items.Count;
58 }
59 }
60
61 private Type ItemType => typeof(DataColumnMapping);
62
63 [Browsable(false)]
65 public DataColumnMapping this[int index]
66 {
67 get
68 {
70 return _items[index];
71 }
72 set
73 {
76 }
77 }
78
79 [Browsable(false)]
81 public DataColumnMapping this[string sourceColumn]
82 {
83 get
84 {
86 return _items[index];
87 }
88 set
89 {
92 }
93 }
94
99
104
105 public int Add(object? value)
106 {
109 return Count - 1;
110 }
111
117
119 {
121 }
122
124 {
126 }
127
128 public void AddRange(Array values)
129 {
131 }
132
134 {
135 if (values == null)
136 {
137 throw ADP.ArgumentNull("values");
138 }
139 foreach (object value2 in values)
140 {
142 }
143 if (doClone)
144 {
145 foreach (ICloneable value3 in values)
146 {
148 }
149 return;
150 }
151 foreach (DataColumnMapping value4 in values)
152 {
154 }
155 }
156
158 {
159 Validate(-1, value);
160 value.Parent = this;
162 }
163
165 {
166 if (_items == null)
167 {
169 }
170 return _items;
171 }
172
173 public void Clear()
174 {
175 if (0 < Count)
176 {
178 }
179 }
180
181 private void ClearWithoutEvents()
182 {
183 if (_items == null)
184 {
185 return;
186 }
187 foreach (DataColumnMapping item in _items)
188 {
189 item.Parent = null;
190 }
191 _items.Clear();
192 }
193
194 public bool Contains(string? value)
195 {
196 return -1 != IndexOf(value);
197 }
198
199 public bool Contains(object? value)
200 {
201 return -1 != IndexOf(value);
202 }
203
204 public void CopyTo(Array array, int index)
205 {
207 }
208
210 {
212 }
213
215 {
216 int num = IndexOfDataSetColumn(value);
217 if (0 > num)
218 {
220 }
221 return _items[num];
222 }
223
225 {
226 return ArrayList().GetEnumerator();
227 }
228
229 public int IndexOf(object? value)
230 {
231 if (value != null)
232 {
234 for (int i = 0; i < Count; i++)
235 {
236 if (_items[i] == value)
237 {
238 return i;
239 }
240 }
241 }
242 return -1;
243 }
244
245 public int IndexOf(string? sourceColumn)
246 {
247 if (!string.IsNullOrEmpty(sourceColumn))
248 {
249 int count = Count;
250 for (int i = 0; i < count; i++)
251 {
252 if (ADP.SrcCompare(sourceColumn, _items[i].SourceColumn) == 0)
253 {
254 return i;
255 }
256 }
257 }
258 return -1;
259 }
260
262 {
263 if (!string.IsNullOrEmpty(dataSetColumn))
264 {
265 int count = Count;
266 for (int i = 0; i < count; i++)
267 {
268 if (ADP.DstCompare(dataSetColumn, _items[i].DataSetColumn) == 0)
269 {
270 return i;
271 }
272 }
273 }
274 return -1;
275 }
276
277 public void Insert(int index, object? value)
278 {
281 }
282
284 {
285 if (value == null)
286 {
287 throw ADP.ColumnsAddNullAttempt("value");
288 }
289 Validate(-1, value);
290 value.Parent = this;
291 ArrayList().Insert(index, value);
292 }
293
294 private void RangeCheck(int index)
295 {
296 if (index < 0 || Count <= index)
297 {
298 throw ADP.ColumnsIndexInt32(index, this);
299 }
300 }
301
302 private int RangeCheck(string sourceColumn)
303 {
304 int num = IndexOf(sourceColumn);
305 if (num < 0)
306 {
308 }
309 return num;
310 }
311
312 public void RemoveAt(int index)
313 {
316 }
317
318 public void RemoveAt(string sourceColumn)
319 {
322 }
323
324 private void RemoveIndex(int index)
325 {
326 _items[index].Parent = null;
327 _items.RemoveAt(index);
328 }
329
330 public void Remove(object? value)
331 {
334 }
335
337 {
338 if (value == null)
339 {
340 throw ADP.ColumnsAddNullAttempt("value");
341 }
342 int num = IndexOf(value);
343 if (-1 != num)
344 {
345 RemoveIndex(num);
346 return;
347 }
348 throw ADP.CollectionRemoveInvalidObject(ItemType, this);
349 }
350
352 {
354 _items[index].Parent = null;
355 newValue.Parent = this;
357 }
358
359 private void ValidateType([NotNull] object value)
360 {
361 if (value == null)
362 {
363 throw ADP.ColumnsAddNullAttempt("value");
364 }
365 if (!ItemType.IsInstanceOfType(value))
366 {
368 }
369 }
370
371 private void Validate(int index, [NotNull] DataColumnMapping value)
372 {
373 if (value == null)
374 {
375 throw ADP.ColumnsAddNullAttempt("value");
376 }
377 if (value.Parent != null)
378 {
379 if (this != value.Parent)
380 {
381 throw ADP.ColumnsIsNotParent(this);
382 }
383 if (index != IndexOf(value))
384 {
385 throw ADP.ColumnsIsParent(this);
386 }
387 }
388 string sourceColumn = value.SourceColumn;
389 if (string.IsNullOrEmpty(sourceColumn))
390 {
391 index = 1;
392 do
393 {
394 sourceColumn = "SourceColumn" + index.ToString(CultureInfo.InvariantCulture);
395 index++;
396 }
397 while (-1 != IndexOf(sourceColumn));
398 value.SourceColumn = sourceColumn;
399 }
400 else
401 {
403 }
404 }
405
406 internal void ValidateSourceColumn(int index, string value)
407 {
408 int num = IndexOf(value);
409 if (-1 != num && index != num)
410 {
412 }
413 }
414
417 {
418 if (columnMappings != null)
419 {
420 int num = columnMappings.IndexOf(sourceColumn);
421 if (-1 != num)
422 {
423 return columnMappings._items[num].GetDataColumnBySchemaAction(dataTable, dataType, schemaAction);
424 }
425 }
426 if (string.IsNullOrEmpty(sourceColumn))
427 {
428 throw ADP.InvalidSourceColumn("sourceColumn");
429 }
430 return mappingAction switch
431 {
432 MissingMappingAction.Passthrough => DataColumnMapping.GetDataColumnBySchemaAction(sourceColumn, sourceColumn, dataTable, dataType, schemaAction),
433 MissingMappingAction.Ignore => null,
434 MissingMappingAction.Error => throw ADP.MissingColumnMapping(sourceColumn),
436 };
437 }
438
441 {
442 if (columnMappings != null)
443 {
444 int num = columnMappings.IndexOf(sourceColumn);
445 if (-1 != num)
446 {
447 return columnMappings._items[num];
448 }
449 }
450 if (string.IsNullOrEmpty(sourceColumn))
451 {
452 throw ADP.InvalidSourceColumn("sourceColumn");
453 }
454 return mappingAction switch
455 {
456 MissingMappingAction.Passthrough => new DataColumnMapping(sourceColumn, sourceColumn),
457 MissingMappingAction.Ignore => null,
458 MissingMappingAction.Error => throw ADP.MissingColumnMapping(sourceColumn),
460 };
461 }
462}
void CopyTo(KeyValuePair< TKey, TValue >[] array, int index)
void Add(TKey key, TValue value)
static Exception ColumnsUniqueSourceColumn(string srcColumn)
Definition ADP.cs:268
static Exception ColumnsIsParent(ICollection collection)
Definition ADP.cs:263
static ArgumentNullException ArgumentNull(string parameter)
Definition ADP.cs:699
static int SrcCompare(string strA, string strB)
Definition ADP.cs:651
static int DstCompare(string strA, string strB)
Definition ADP.cs:952
static Exception NotADataColumnMapping(object value)
Definition ADP.cs:273
static Exception ColumnsIndexSource(string srcColumn)
Definition ADP.cs:253
static Exception ColumnsDataSetColumn(string cacheColumn)
Definition ADP.cs:243
static Exception ColumnsAddNullAttempt(string parameter)
Definition ADP.cs:238
static ArgumentException CollectionRemoveInvalidObject(Type itemType, ICollection collection)
Definition ADP.cs:830
static Exception ColumnsIndexInt32(int index, IColumnMappingCollection collection)
Definition ADP.cs:248
static InvalidOperationException MissingColumnMapping(string srcColumn)
Definition ADP.cs:213
static Exception InvalidSourceColumn(string parameter)
Definition ADP.cs:233
static ArgumentOutOfRangeException InvalidMissingMappingAction(MissingMappingAction value)
Definition ADP.cs:129
static Exception ColumnsIsNotParent(ICollection collection)
Definition ADP.cs:258
void CopyTo(DataColumnMapping[] array, int index)
void Insert(int index, DataColumnMapping value)
DataColumnMapping Add(string? sourceColumn, string? dataSetColumn)
static ? DataColumn GetDataColumn(DataColumnMappingCollection? columnMappings, string sourceColumn, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicFields|DynamicallyAccessedMemberTypes.PublicProperties)] Type? dataType, DataTable dataTable, MissingMappingAction mappingAction, MissingSchemaAction schemaAction)
static ? DataColumnMapping GetColumnMappingBySchemaAction(DataColumnMappingCollection? columnMappings, string sourceColumn, MissingMappingAction mappingAction)
void Validate(int index, [NotNull] DataColumnMapping value)
void Replace(int index, DataColumnMapping newValue)
IColumnMapping IColumnMappingCollection. GetByDataSetColumn(string dataSetColumnName)
void AddEnumerableRange(IEnumerable values, bool doClone)
void AddWithoutEvents([NotNull] DataColumnMapping value)
DataColumnMapping Add(DataColumnMapping value)
DataColumn? GetDataColumnBySchemaAction(DataTable dataTable, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicFields|DynamicallyAccessedMemberTypes.PublicProperties)] Type? dataType, MissingSchemaAction schemaAction)
static CultureInfo InvariantCulture
IColumnMapping Add(string sourceColumnName, string dataSetColumnName)
IColumnMapping GetByDataSetColumn(string dataSetColumnName)