Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
RecordManager.cs
Go to the documentation of this file.
3
4namespace System.Data;
5
6internal sealed class RecordManager
7{
8 private readonly DataTable _table;
9
10 private int _lastFreeRecord;
11
12 private int _minimumCapacity = 50;
13
14 private int _recordCapacity;
15
16 private readonly List<int> _freeRecordList = new List<int>();
17
18 private DataRow[] _rows;
19
21
22 internal int MinimumCapacity
23 {
24 get
25 {
26 return _minimumCapacity;
27 }
28 set
29 {
31 {
32 if (value < 0)
33 {
35 }
37 }
38 }
39 }
40
41 internal int RecordCapacity
42 {
43 get
44 {
45 return _recordCapacity;
46 }
47 set
48 {
50 {
51 for (int i = 0; i < _table.Columns.Count; i++)
52 {
53 _table.Columns[i].SetCapacity(value);
54 }
56 }
57 }
58 }
59
60 internal DataRow this[int record]
61 {
62 get
63 {
64 return _rows[record];
65 }
66 set
67 {
69 }
70 }
71
72 internal RecordManager(DataTable table)
73 {
74 if (table == null)
75 {
76 throw ExceptionBuilder.ArgumentNull("table");
77 }
78 _table = table;
79 }
80
91
92 internal static int NewCapacity(int capacity)
93 {
94 if (capacity >= 128)
95 {
96 return capacity + capacity;
97 }
98 return 128;
99 }
100
102 {
103 if (capacity < 1014)
104 {
105 if (capacity < 246)
106 {
107 if (capacity < 54)
108 {
109 return 64;
110 }
111 return 256;
112 }
113 return 1024;
114 }
115 return (capacity + 10 >> 10) + 1 << 10;
116 }
117
118 internal int NewRecordBase()
119 {
120 int result;
121 if (_freeRecordList.Count != 0)
122 {
123 result = _freeRecordList[_freeRecordList.Count - 1];
125 }
126 else
127 {
129 {
131 }
132 result = _lastFreeRecord;
134 }
135 return result;
136 }
137
138 internal void FreeRecord(ref int record)
139 {
140 if (-1 != record)
141 {
142 _rows[record] = null;
144 for (int i = 0; i < count; i++)
145 {
146 _table._columnCollection[i].FreeRecord(record);
147 }
148 if (_lastFreeRecord == record + 1)
149 {
151 }
152 else if (record < _lastFreeRecord)
153 {
155 }
156 record = -1;
157 }
158 }
159
160 internal void Clear(bool clearAll)
161 {
162 if (clearAll)
163 {
164 for (int i = 0; i < _recordCapacity; i++)
165 {
166 _rows[i] = null;
167 }
169 for (int j = 0; j < count; j++)
170 {
172 for (int k = 0; k < _recordCapacity; k++)
173 {
174 dataColumn.FreeRecord(k);
175 }
176 }
177 _lastFreeRecord = 0;
179 return;
180 }
181 _freeRecordList.Capacity = _freeRecordList.Count + _table.Rows.Count;
182 for (int l = 0; l < _recordCapacity; l++)
183 {
185 if (dataRow != null && dataRow.rowID != -1)
186 {
187 int record = l;
189 }
190 }
191 }
192
193 internal int ImportRecord(DataTable src, int record)
194 {
195 return CopyRecord(src, record, -1);
196 }
197
198 internal int CopyRecord(DataTable src, int record, int copy)
199 {
200 if (record == -1)
201 {
202 return copy;
203 }
204 int record2 = -1;
205 try
206 {
209 for (int i = 0; i < count; i++)
210 {
212 DataColumn dataColumn2 = src.Columns[dataColumn.ColumnName];
213 if (dataColumn2 != null)
214 {
215 object obj = dataColumn2[record];
217 {
218 dataColumn[record2] = cloneable.Clone();
219 }
220 else
221 {
223 }
224 }
225 else if (-1 == copy)
226 {
227 dataColumn.Init(record2);
228 }
229 }
230 return record2;
231 }
233 {
234 if (-1 == copy)
235 {
237 }
238 throw;
239 }
240 }
241
242 internal void SetRowCache(DataRow[] newRows)
243 {
244 _rows = newRows;
245 _lastFreeRecord = _rows.Length;
247 }
248}
static unsafe void Copy(Array sourceArray, Array destinationArray, int length)
Definition Array.cs:624
void RemoveAt(int index)
Definition List.cs:824
static bool IsCatchableOrSecurityExceptionType(Exception e)
Definition ADP.cs:800
readonly DataColumnCollection _columnCollection
Definition DataTable.cs:64
DataRowCollection Rows
Definition DataTable.cs:701
DataColumnCollection Columns
Definition DataTable.cs:327
DataRow[] NewRowArray(int size)
static Exception NegativeMinimumCapacity()
static Exception ArgumentNull(string paramName)
RecordManager(DataTable table)
int ImportRecord(DataTable src, int record)
void SetRowCache(DataRow[] newRows)
int CopyRecord(DataTable src, int record, int copy)
static int NewCapacity(int capacity)
readonly DataTable _table
void Clear(bool clearAll)
void FreeRecord(ref int record)
int NormalizedMinimumCapacity(int capacity)
readonly List< int > _freeRecordList
static byte Min(byte val1, byte val2)
Definition Math.cs:912