Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
DataError.cs
Go to the documentation of this file.
2
3namespace System.Data;
4
5internal sealed class DataError
6{
7 internal struct ColumnError
8 {
10
11 internal string _error;
12 }
13
14 private string _rowError = string.Empty;
15
16 private int _count;
17
19
20 internal string Text
21 {
22 get
23 {
24 return _rowError;
25 }
26 [param: AllowNull]
27 set
28 {
30 }
31 }
32
33 internal bool HasErrors
34 {
35 get
36 {
37 if (_rowError.Length == 0)
38 {
39 return _count != 0;
40 }
41 return true;
42 }
43 }
44
45 internal DataError()
46 {
47 }
48
49 internal DataError(string rowError)
50 {
51 SetText(rowError);
52 }
53
54 internal void SetColumnError(DataColumn column, string error)
55 {
56 if (error == null || error.Length == 0)
57 {
58 Clear(column);
59 return;
60 }
61 if (_errorList == null)
62 {
63 _errorList = new ColumnError[1];
64 }
65 int num = IndexOf(column);
66 _errorList[num]._column = column;
67 _errorList[num]._error = error;
68 column._errors++;
69 if (num == _count)
70 {
71 _count++;
72 }
73 }
74
75 internal string GetColumnError(DataColumn column)
76 {
77 for (int i = 0; i < _count; i++)
78 {
79 if (_errorList[i]._column == column)
80 {
81 return _errorList[i]._error;
82 }
83 }
84 return string.Empty;
85 }
86
87 internal void Clear(DataColumn column)
88 {
89 if (_count == 0)
90 {
91 return;
92 }
93 for (int i = 0; i < _count; i++)
94 {
95 if (_errorList[i]._column == column)
96 {
97 Array.Copy(_errorList, i + 1, _errorList, i, _count - i - 1);
98 _count--;
99 column._errors--;
100 }
101 }
102 }
103
104 internal void Clear()
105 {
106 for (int i = 0; i < _count; i++)
107 {
109 }
110 _count = 0;
111 _rowError = string.Empty;
112 }
113
115 {
117 for (int i = 0; i < _count; i++)
118 {
119 array[i] = _errorList[i]._column;
120 }
121 return array;
122 }
123
124 private void SetText(string errorText)
125 {
126 if (errorText == null)
127 {
128 errorText = string.Empty;
129 }
130 _rowError = errorText;
131 }
132
133 internal int IndexOf(DataColumn column)
134 {
135 for (int i = 0; i < _count; i++)
136 {
137 if (_errorList[i]._column == column)
138 {
139 return i;
140 }
141 }
142 if (_count >= _errorList.Length)
143 {
144 int num = Math.Min(_count * 2, column.Table.Columns.Count);
145 ColumnError[] array = new ColumnError[num];
148 }
149 return _count;
150 }
151}
static unsafe void Copy(Array sourceArray, Array destinationArray, int length)
Definition Array.cs:624
int IndexOf(DataColumn column)
Definition DataError.cs:133
void SetText(string errorText)
Definition DataError.cs:124
string GetColumnError(DataColumn column)
Definition DataError.cs:75
void SetColumnError(DataColumn column, string error)
Definition DataError.cs:54
DataError(string rowError)
Definition DataError.cs:49
void Clear(DataColumn column)
Definition DataError.cs:87
ColumnError[] _errorList
Definition DataError.cs:18
DataColumn[] GetColumnsInError()
Definition DataError.cs:114
DataColumnCollection Columns
Definition DataTable.cs:327
static byte Min(byte val1, byte val2)
Definition Math.cs:912