Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
UInt32Storage.cs
Go to the documentation of this file.
3using System.Xml;
4
5namespace System.Data.Common;
6
7internal sealed class UInt32Storage : DataStorage
8{
9 private uint[] _values;
10
13 {
14 }
15
16 public override object Aggregate(int[] records, AggregateType kind)
17 {
18 bool flag = false;
19 try
20 {
21 switch (kind)
22 {
23 case AggregateType.Sum:
24 {
25 ulong num4 = 0uL;
26 foreach (int num5 in records)
27 {
28 if (HasValue(num5))
29 {
31 flag = true;
32 }
33 }
34 if (flag)
35 {
36 return num4;
37 }
38 return _nullValue;
39 }
40 case AggregateType.Mean:
41 {
42 long num11 = 0L;
43 int num12 = 0;
44 foreach (int num13 in records)
45 {
46 if (HasValue(num13))
47 {
49 num12++;
50 flag = true;
51 }
52 }
54 {
55 if (flag)
56 {
57 uint num14 = (uint)unchecked(num11 / num12);
58 return num14;
59 }
60 return _nullValue;
61 }
62 }
63 case AggregateType.Var:
64 case AggregateType.StDev:
65 {
66 int num = 0;
67 double num6 = 0.0;
68 double num7 = 0.0;
69 double num8 = 0.0;
70 double num9 = 0.0;
71 foreach (int num10 in records)
72 {
73 if (HasValue(num10))
74 {
75 num8 += (double)_values[num10];
76 num9 += (double)_values[num10] * (double)_values[num10];
77 num++;
78 }
79 }
80 if (num > 1)
81 {
82 num6 = (double)num * num9 - num8 * num8;
83 num7 = num6 / (num8 * num8);
84 num6 = ((!(num7 < 1E-15) && !(num6 < 0.0)) ? (num6 / (double)(num * (num - 1))) : 0.0);
85 if (kind == AggregateType.StDev)
86 {
87 return Math.Sqrt(num6);
88 }
89 return num6;
90 }
91 return _nullValue;
92 }
93 case AggregateType.Min:
94 {
95 uint num2 = uint.MaxValue;
96 foreach (int num3 in records)
97 {
98 if (HasValue(num3))
99 {
101 flag = true;
102 }
103 }
104 if (flag)
105 {
106 return num2;
107 }
108 return _nullValue;
109 }
110 case AggregateType.Max:
111 {
112 uint num15 = 0u;
113 foreach (int num16 in records)
114 {
115 if (HasValue(num16))
116 {
118 flag = true;
119 }
120 }
121 if (flag)
122 {
123 return num15;
124 }
125 return _nullValue;
126 }
127 case AggregateType.First:
128 if (records.Length != 0)
129 {
130 return _values[records[0]];
131 }
132 return null;
133 case AggregateType.Count:
134 {
135 int num = 0;
136 for (int i = 0; i < records.Length; i++)
137 {
138 if (HasValue(records[i]))
139 {
140 num++;
141 }
142 }
143 return num;
144 }
145 }
146 }
147 catch (OverflowException)
148 {
149 throw ExprException.Overflow(typeof(uint));
150 }
152 }
153
154 public override int Compare(int recordNo1, int recordNo2)
155 {
156 uint num = _values[recordNo1];
157 uint num2 = _values[recordNo2];
158 if (num == 0 || num2 == 0)
159 {
161 if (num3 != 0)
162 {
163 return num3;
164 }
165 }
166 if (num >= num2)
167 {
168 if (num <= num2)
169 {
170 return 0;
171 }
172 return 1;
173 }
174 return -1;
175 }
176
177 public override int CompareValueTo(int recordNo, object value)
178 {
179 if (_nullValue == value)
180 {
181 if (!HasValue(recordNo))
182 {
183 return 0;
184 }
185 return 1;
186 }
187 uint num = _values[recordNo];
188 if (num == 0 && !HasValue(recordNo))
189 {
190 return -1;
191 }
192 return num.CompareTo((uint)value);
193 }
194
195 public override object ConvertValue(object value)
196 {
197 if (_nullValue != value)
198 {
199 value = ((value == null) ? _nullValue : ((object)((IConvertible)value).ToUInt32(base.FormatProvider)));
200 }
201 return value;
202 }
203
204 public override void Copy(int recordNo1, int recordNo2)
205 {
208 }
209
210 public override object Get(int record)
211 {
212 uint num = _values[record];
213 if (!num.Equals(0u))
214 {
215 return num;
216 }
217 return GetBits(record);
218 }
219
220 public override void Set(int record, object value)
221 {
222 if (_nullValue == value)
223 {
224 _values[record] = 0u;
225 SetNullBit(record, flag: true);
226 }
227 else
228 {
229 _values[record] = ((IConvertible)value).ToUInt32(base.FormatProvider);
230 SetNullBit(record, flag: false);
231 }
232 }
233
234 public override void SetCapacity(int capacity)
235 {
236 uint[] array = new uint[capacity];
237 if (_values != null)
238 {
240 }
241 _values = array;
242 base.SetCapacity(capacity);
243 }
244
245 [RequiresUnreferencedCode("Members from serialized types may be trimmed if not referenced directly.")]
246 public override object ConvertXmlToObject(string s)
247 {
248 return XmlConvert.ToUInt32(s);
249 }
250
251 [RequiresUnreferencedCode("Members from serialized types may be trimmed if not referenced directly.")]
252 public override string ConvertObjectToXml(object value)
253 {
254 return XmlConvert.ToString((uint)value);
255 }
256
257 protected override object GetEmptyStorage(int recordCount)
258 {
259 return new uint[recordCount];
260 }
261
262 protected override void CopyValue(int record, object store, BitArray nullbits, int storeIndex)
263 {
264 uint[] array = (uint[])store;
267 }
268
269 protected override void SetStorage(object store, BitArray nullbits)
270 {
271 _values = (uint[])store;
273 }
274}
static unsafe void Copy(Array sourceArray, Array destinationArray, int length)
Definition Array.cs:624
void SetNullStorage(BitArray nullbits)
int CompareBits(int recordNo1, int recordNo2)
bool HasValue(int recordNo)
void SetNullBit(int recordNo, bool flag)
void CopyBits(int srcRecordNo, int dstRecordNo)
object GetBits(int recordNo)
override int CompareValueTo(int recordNo, object value)
override void SetStorage(object store, BitArray nullbits)
override void CopyValue(int record, object store, BitArray nullbits, int storeIndex)
override object GetEmptyStorage(int recordCount)
override void Set(int record, object value)
override object Get(int record)
override object Aggregate(int[] records, AggregateType kind)
override string ConvertObjectToXml(object value)
override void Copy(int recordNo1, int recordNo2)
override object ConvertValue(object value)
override void SetCapacity(int capacity)
override int Compare(int recordNo1, int recordNo2)
override object ConvertXmlToObject(string s)
static Exception AggregateException(AggregateType aggregateType, Type type)
static Exception Overflow(Type type)
static byte Min(byte val1, byte val2)
Definition Math.cs:912
static double Sqrt(double d)
static byte Max(byte val1, byte val2)
Definition Math.cs:738
static uint ToUInt32(string s)
static string ToString(bool value)