Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
SqlInt16Storage.cs
Go to the documentation of this file.
4using System.IO;
5using System.Xml;
7
8namespace System.Data.Common;
9
10internal sealed class SqlInt16Storage : DataStorage
11{
12 private SqlInt16[] _values;
13
18
19 public override object Aggregate(int[] records, AggregateType kind)
20 {
21 bool flag = false;
22 try
23 {
24 switch (kind)
25 {
26 case AggregateType.Sum:
27 {
29 foreach (int num3 in records)
30 {
31 if (!IsNull(num3))
32 {
34 flag = true;
35 }
36 }
37 if (flag)
38 {
39 return sqlInt2;
40 }
41 return _nullValue;
42 }
43 case AggregateType.Mean:
44 {
46 int num5 = 0;
47 foreach (int num6 in records)
48 {
49 if (!IsNull(num6))
50 {
52 num5++;
53 flag = true;
54 }
55 }
56 if (flag)
57 {
59 sqlInt4 = (sqlInt3 / num5).ToSqlInt16();
60 return sqlInt4;
61 }
62 return _nullValue;
63 }
64 case AggregateType.Var:
65 case AggregateType.StDev:
66 {
67 int num = 0;
68 SqlDouble sqlDouble = 0.0;
72 foreach (int num4 in records)
73 {
74 if (!IsNull(num4))
75 {
78 num++;
79 }
80 }
81 if (num > 1)
82 {
85 if (sqlDouble2 < 1E-15 || sqlDouble < 0.0)
86 {
87 sqlDouble = 0.0;
88 }
89 else
90 {
91 sqlDouble /= (SqlDouble)(num * (num - 1));
92 }
93 if (kind == AggregateType.StDev)
94 {
95 return Math.Sqrt(sqlDouble.Value);
96 }
97 return sqlDouble;
98 }
99 return _nullValue;
100 }
101 case AggregateType.Min:
102 {
104 foreach (int num2 in records)
105 {
106 if (!IsNull(num2))
107 {
108 if (SqlInt16.LessThan(_values[num2], sqlInt).IsTrue)
109 {
111 }
112 flag = true;
113 }
114 }
115 if (flag)
116 {
117 return sqlInt;
118 }
119 return _nullValue;
120 }
121 case AggregateType.Max:
122 {
124 foreach (int num7 in records)
125 {
126 if (!IsNull(num7))
127 {
129 {
131 }
132 flag = true;
133 }
134 }
135 if (flag)
136 {
137 return sqlInt5;
138 }
139 return _nullValue;
140 }
141 case AggregateType.First:
142 if (records.Length != 0)
143 {
144 return _values[records[0]];
145 }
146 return null;
147 case AggregateType.Count:
148 {
149 int num = 0;
150 for (int i = 0; i < records.Length; i++)
151 {
152 if (!IsNull(records[i]))
153 {
154 num++;
155 }
156 }
157 return num;
158 }
159 }
160 }
161 catch (OverflowException)
162 {
164 }
166 }
167
168 public override int Compare(int recordNo1, int recordNo2)
169 {
171 }
172
173 public override int CompareValueTo(int recordNo, object value)
174 {
176 }
177
178 public override object ConvertValue(object value)
179 {
180 if (value != null)
181 {
183 }
184 return _nullValue;
185 }
186
187 public override void Copy(int recordNo1, int recordNo2)
188 {
190 }
191
192 public override object Get(int record)
193 {
194 return _values[record];
195 }
196
197 public override bool IsNull(int record)
198 {
199 return _values[record].IsNull;
200 }
201
202 public override void Set(int record, object value)
203 {
205 }
206
207 public override void SetCapacity(int capacity)
208 {
210 if (_values != null)
211 {
213 }
214 _values = array;
215 }
216
217 [RequiresUnreferencedCode("Members from serialized types may be trimmed if not referenced directly.")]
218 public override object ConvertXmlToObject(string s)
219 {
220 SqlInt16 sqlInt = default(SqlInt16);
221 string s2 = "<col>" + s + "</col>";
224 using (XmlTextReader reader = new XmlTextReader(input))
225 {
226 xmlSerializable.ReadXml(reader);
227 }
228 return (SqlInt16)(object)xmlSerializable;
229 }
230
231 [RequiresUnreferencedCode("Members from serialized types may be trimmed if not referenced directly.")]
232 public override string ConvertObjectToXml(object value)
233 {
234 StringWriter stringWriter = new StringWriter(base.FormatProvider);
236 {
237 ((IXmlSerializable)value).WriteXml(writer);
238 }
239 return stringWriter.ToString();
240 }
241
242 protected override object GetEmptyStorage(int recordCount)
243 {
244 return new SqlInt16[recordCount];
245 }
246
247 protected override void CopyValue(int record, object store, BitArray nullbits, int storeIndex)
248 {
252 }
253
254 protected override void SetStorage(object store, BitArray nullbits)
255 {
257 }
258}
static unsafe void Copy(Array sourceArray, Array destinationArray, int length)
Definition Array.cs:624
static SqlInt16 ConvertToSqlInt16(object value)
Definition SqlConvert.cs:25
override void Copy(int recordNo1, int recordNo2)
override object ConvertXmlToObject(string s)
override string ConvertObjectToXml(object value)
override bool IsNull(int record)
override object GetEmptyStorage(int recordCount)
override void CopyValue(int record, object store, BitArray nullbits, int storeIndex)
override object ConvertValue(object value)
override void SetStorage(object store, BitArray nullbits)
override int Compare(int recordNo1, int recordNo2)
override void SetCapacity(int capacity)
override object Aggregate(int[] records, AggregateType kind)
override int CompareValueTo(int recordNo, object value)
override object Get(int record)
override void Set(int record, object value)
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 SqlBoolean LessThan(SqlInt16 x, SqlInt16 y)
Definition SqlInt16.cs:410
static SqlBoolean GreaterThan(SqlInt16 x, SqlInt16 y)
Definition SqlInt16.cs:415
static readonly SqlInt16 MinValue
Definition SqlInt16.cs:23
int CompareTo(object? value)
Definition SqlInt16.cs:475
static readonly SqlInt16 MaxValue
Definition SqlInt16.cs:25