Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
DataTableExtensions.cs
Go to the documentation of this file.
3
4namespace System.Data;
5
6public static class DataTableExtensions
7{
9 {
10 DataSetUtil.CheckArgumentNull(source, "source");
12 }
13
15 {
16 DataSetUtil.CheckArgumentNull(source, "source");
17 return LoadTableFromEnumerable(source, null, null, null);
18 }
19
21 {
22 DataSetUtil.CheckArgumentNull(source, "source");
23 DataSetUtil.CheckArgumentNull(table, "table");
25 }
26
28 {
29 DataSetUtil.CheckArgumentNull(source, "source");
30 DataSetUtil.CheckArgumentNull(table, "table");
32 }
33
35 {
36 if (options.HasValue)
37 {
38 LoadOption value = options.Value;
39 if ((uint)(value - 1) > 2u)
40 {
42 }
43 }
45 {
46 if (!enumerator.MoveNext())
47 {
49 }
50 if (table == null)
51 {
52 DataRow current = enumerator.Current;
53 if (current == null)
54 {
56 }
57 table = new DataTable
58 {
59 Locale = CultureInfo.CurrentCulture
60 };
61 foreach (DataColumn column in current.Table.Columns)
62 {
63 table.Columns.Add(column.ColumnName, column.DataType);
64 }
65 }
66 table.BeginLoadData();
67 try
68 {
69 do
70 {
71 DataRow current = enumerator.Current;
72 if (current == null)
73 {
74 continue;
75 }
76 object[] values = null;
77 try
78 {
79 switch (current.RowState)
80 {
81 case DataRowState.Detached:
82 if (!current.HasVersion(DataRowVersion.Proposed))
83 {
85 }
86 goto case DataRowState.Unchanged;
87 case DataRowState.Unchanged:
88 case DataRowState.Added:
89 case DataRowState.Modified:
90 values = current.ItemArray;
91 if (options.HasValue)
92 {
93 table.LoadDataRow(values, options.Value);
94 }
95 else
96 {
97 table.LoadDataRow(values, fAcceptChanges: true);
98 }
99 break;
100 case DataRowState.Deleted:
102 default:
104 }
105 }
106 catch (Exception ex)
107 {
109 {
110 throw;
111 }
113 if (errorHandler != null)
114 {
116 {
117 Errors = ex
118 };
120 }
121 if (fillErrorEventArgs == null)
122 {
123 throw;
124 }
125 if (!fillErrorEventArgs.Continue)
126 {
127 if ((fillErrorEventArgs.Errors ?? ex) == ex)
128 {
129 throw;
130 }
131 throw fillErrorEventArgs.Errors;
132 }
133 }
134 }
135 while (enumerator.MoveNext());
136 }
137 finally
138 {
139 table.EndLoadData();
140 }
141 }
142 return table;
143 }
144
145 public static DataView AsDataView(this DataTable table)
146 {
147 DataSetUtil.CheckArgumentNull(table, "table");
148 return new LinqDataView(table, null);
149 }
150
152 {
153 DataSetUtil.CheckArgumentNull(source, "source");
154 return source.GetLinqDataView();
155 }
156}
static ArgumentOutOfRangeException InvalidDataRowState(DataRowState value)
static InvalidOperationException InvalidOperation(string message)
static ArgumentOutOfRangeException InvalidLoadOption(LoadOption value)
static bool IsCatchableExceptionType(Exception e)
bool HasVersion(DataRowVersion version)
Definition DataRow.cs:941
object?[] ItemArray
Definition DataRow.cs:303
DataRowState RowState
Definition DataRow.cs:134
static DataView AsDataView< T >(this EnumerableRowCollection< T > source)
static EnumerableRowCollection< DataRow > AsEnumerable(this DataTable source)
static DataView AsDataView(this DataTable table)
static DataTable CopyToDataTable< T >(this IEnumerable< T > source)
static DataTable LoadTableFromEnumerable< T >(IEnumerable< T > source, DataTable table, LoadOption? options, FillErrorEventHandler errorHandler)
DataColumnCollection Columns
Definition DataTable.cs:327
static string DataSetLinq_CannotLoadDetachedRow
Definition SR.cs:930
static string DataSetLinq_CannotLoadDeletedRow
Definition SR.cs:934
static string DataSetLinq_NullDataRow
Definition SR.cs:928
static string DataSetLinq_EmptyDataRowSource
Definition SR.cs:926
Definition SR.cs:7
delegate void FillErrorEventHandler(object sender, FillErrorEventArgs e)