Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
SqlInt16.cs
Go to the documentation of this file.
4using System.Xml;
7
9
11[XmlSchemaProvider("GetXsdType")]
12[TypeForwardedFrom("System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
14{
15 private bool m_fNotNull;
16
17 private short m_value;
18
19 public static readonly SqlInt16 Null = new SqlInt16(fNull: true);
20
21 public static readonly SqlInt16 Zero = new SqlInt16(0);
22
23 public static readonly SqlInt16 MinValue = new SqlInt16(short.MinValue);
24
25 public static readonly SqlInt16 MaxValue = new SqlInt16(short.MaxValue);
26
27 public bool IsNull => !m_fNotNull;
28
29 public short Value
30 {
31 get
32 {
33 if (m_fNotNull)
34 {
35 return m_value;
36 }
37 throw new SqlNullValueException();
38 }
39 }
40
41 private SqlInt16(bool fNull)
42 {
43 m_fNotNull = false;
44 m_value = 0;
45 }
46
47 public SqlInt16(short value)
48 {
49 m_value = value;
50 m_fNotNull = true;
51 }
52
53 public static implicit operator SqlInt16(short x)
54 {
55 return new SqlInt16(x);
56 }
57
58 public static explicit operator short(SqlInt16 x)
59 {
60 return x.Value;
61 }
62
63 public override string ToString()
64 {
65 if (!IsNull)
66 {
67 return m_value.ToString((IFormatProvider?)null);
68 }
70 }
71
72 public static SqlInt16 Parse(string s)
73 {
75 {
76 return Null;
77 }
78 return new SqlInt16(short.Parse(s, null));
79 }
80
81 public static SqlInt16 operator -(SqlInt16 x)
82 {
83 if (!x.IsNull)
84 {
85 return new SqlInt16((short)(-x.m_value));
86 }
87 return Null;
88 }
89
90 public static SqlInt16 operator ~(SqlInt16 x)
91 {
92 if (!x.IsNull)
93 {
94 return new SqlInt16((short)(~x.m_value));
95 }
96 return Null;
97 }
98
100 {
101 if (x.IsNull || y.IsNull)
102 {
103 return Null;
104 }
105 int num = x.m_value + y.m_value;
106 if (((uint)((num >> 15) ^ (num >> 16)) & (true ? 1u : 0u)) != 0)
107 {
109 }
110 return new SqlInt16((short)num);
111 }
112
114 {
115 if (x.IsNull || y.IsNull)
116 {
117 return Null;
118 }
119 int num = x.m_value - y.m_value;
120 if (((uint)((num >> 15) ^ (num >> 16)) & (true ? 1u : 0u)) != 0)
121 {
123 }
124 return new SqlInt16((short)num);
125 }
126
128 {
129 if (x.IsNull || y.IsNull)
130 {
131 return Null;
132 }
133 int num = x.m_value * y.m_value;
134 int num2 = num & -32768;
135 if (num2 != 0 && num2 != -32768)
136 {
138 }
139 return new SqlInt16((short)num);
140 }
141
143 {
144 if (x.IsNull || y.IsNull)
145 {
146 return Null;
147 }
148 if (y.m_value != 0)
149 {
150 if (x.m_value == short.MinValue && y.m_value == -1)
151 {
153 }
154 return new SqlInt16((short)(x.m_value / y.m_value));
155 }
157 }
158
160 {
161 if (x.IsNull || y.IsNull)
162 {
163 return Null;
164 }
165 if (y.m_value != 0)
166 {
167 if (x.m_value == short.MinValue && y.m_value == -1)
168 {
170 }
171 return new SqlInt16((short)(x.m_value % y.m_value));
172 }
174 }
175
177 {
178 if (!x.IsNull && !y.IsNull)
179 {
180 return new SqlInt16((short)(x.m_value & y.m_value));
181 }
182 return Null;
183 }
184
186 {
187 if (!x.IsNull && !y.IsNull)
188 {
189 return new SqlInt16((short)((ushort)x.m_value | (ushort)y.m_value));
190 }
191 return Null;
192 }
193
195 {
196 if (!x.IsNull && !y.IsNull)
197 {
198 return new SqlInt16((short)(x.m_value ^ y.m_value));
199 }
200 return Null;
201 }
202
203 public static explicit operator SqlInt16(SqlBoolean x)
204 {
205 if (!x.IsNull)
206 {
207 return new SqlInt16(x.ByteValue);
208 }
209 return Null;
210 }
211
212 public static implicit operator SqlInt16(SqlByte x)
213 {
214 if (!x.IsNull)
215 {
216 return new SqlInt16(x.Value);
217 }
218 return Null;
219 }
220
221 public static explicit operator SqlInt16(SqlInt32 x)
222 {
223 if (x.IsNull)
224 {
225 return Null;
226 }
227 int value = x.Value;
228 if (value > 32767 || value < -32768)
229 {
231 }
232 return new SqlInt16((short)value);
233 }
234
235 public static explicit operator SqlInt16(SqlInt64 x)
236 {
237 if (x.IsNull)
238 {
239 return Null;
240 }
241 long value = x.Value;
242 if (value > 32767 || value < -32768)
243 {
245 }
246 return new SqlInt16((short)value);
247 }
248
249 public static explicit operator SqlInt16(SqlSingle x)
250 {
251 if (x.IsNull)
252 {
253 return Null;
254 }
255 float value = x.Value;
257 {
259 }
260 return new SqlInt16((short)value);
261 }
262
263 public static explicit operator SqlInt16(SqlDouble x)
264 {
265 if (x.IsNull)
266 {
267 return Null;
268 }
269 double value = x.Value;
270 if (value < -32768.0 || value > 32767.0)
271 {
273 }
274 return new SqlInt16((short)value);
275 }
276
277 public static explicit operator SqlInt16(SqlMoney x)
278 {
279 if (!x.IsNull)
280 {
281 return new SqlInt16(checked((short)x.ToInt32()));
282 }
283 return Null;
284 }
285
286 public static explicit operator SqlInt16(SqlDecimal x)
287 {
288 return (SqlInt16)(SqlInt32)x;
289 }
290
291 public static explicit operator SqlInt16(SqlString x)
292 {
293 if (!x.IsNull)
294 {
295 return new SqlInt16(short.Parse(x.Value, null));
296 }
297 return Null;
298 }
299
301 {
302 if (!x.IsNull && !y.IsNull)
303 {
304 return new SqlBoolean(x.m_value == y.m_value);
305 }
306 return SqlBoolean.Null;
307 }
308
310 {
311 return !(x == y);
312 }
313
315 {
316 if (!x.IsNull && !y.IsNull)
317 {
318 return new SqlBoolean(x.m_value < y.m_value);
319 }
320 return SqlBoolean.Null;
321 }
322
324 {
325 if (!x.IsNull && !y.IsNull)
326 {
327 return new SqlBoolean(x.m_value > y.m_value);
328 }
329 return SqlBoolean.Null;
330 }
331
333 {
334 if (!x.IsNull && !y.IsNull)
335 {
336 return new SqlBoolean(x.m_value <= y.m_value);
337 }
338 return SqlBoolean.Null;
339 }
340
342 {
343 if (!x.IsNull && !y.IsNull)
344 {
345 return new SqlBoolean(x.m_value >= y.m_value);
346 }
347 return SqlBoolean.Null;
348 }
349
351 {
352 return ~x;
353 }
354
355 public static SqlInt16 Add(SqlInt16 x, SqlInt16 y)
356 {
357 return x + y;
358 }
359
360 public static SqlInt16 Subtract(SqlInt16 x, SqlInt16 y)
361 {
362 return x - y;
363 }
364
365 public static SqlInt16 Multiply(SqlInt16 x, SqlInt16 y)
366 {
367 return x * y;
368 }
369
370 public static SqlInt16 Divide(SqlInt16 x, SqlInt16 y)
371 {
372 return x / y;
373 }
374
375 public static SqlInt16 Mod(SqlInt16 x, SqlInt16 y)
376 {
377 return x % y;
378 }
379
380 public static SqlInt16 Modulus(SqlInt16 x, SqlInt16 y)
381 {
382 return x % y;
383 }
384
386 {
387 return x & y;
388 }
389
391 {
392 return x | y;
393 }
394
395 public static SqlInt16 Xor(SqlInt16 x, SqlInt16 y)
396 {
397 return x ^ y;
398 }
399
400 public static SqlBoolean Equals(SqlInt16 x, SqlInt16 y)
401 {
402 return x == y;
403 }
404
406 {
407 return x != y;
408 }
409
411 {
412 return x < y;
413 }
414
416 {
417 return x > y;
418 }
419
421 {
422 return x <= y;
423 }
424
426 {
427 return x >= y;
428 }
429
431 {
432 return (SqlBoolean)this;
433 }
434
436 {
437 return (SqlByte)this;
438 }
439
441 {
442 return this;
443 }
444
446 {
447 return this;
448 }
449
451 {
452 return this;
453 }
454
456 {
457 return this;
458 }
459
461 {
462 return this;
463 }
464
466 {
467 return this;
468 }
469
471 {
472 return (SqlString)this;
473 }
474
475 public int CompareTo(object? value)
476 {
478 {
479 return CompareTo(value2);
480 }
481 throw ADP.WrongType(value.GetType(), typeof(SqlInt16));
482 }
483
485 {
486 if (IsNull)
487 {
488 if (!value.IsNull)
489 {
490 return -1;
491 }
492 return 0;
493 }
494 if (value.IsNull)
495 {
496 return 1;
497 }
498 if (this < value)
499 {
500 return -1;
501 }
502 if (this > value)
503 {
504 return 1;
505 }
506 return 0;
507 }
508
509 public override bool Equals([NotNullWhen(true)] object? value)
510 {
511 if (!(value is SqlInt16 sqlInt))
512 {
513 return false;
514 }
515 if (sqlInt.IsNull || IsNull)
516 {
517 if (sqlInt.IsNull)
518 {
519 return IsNull;
520 }
521 return false;
522 }
523 return (this == sqlInt).Value;
524 }
525
526 public override int GetHashCode()
527 {
528 if (!IsNull)
529 {
530 return Value.GetHashCode();
531 }
532 return 0;
533 }
534
536 {
537 return null;
538 }
539
541 {
542 string attribute = reader.GetAttribute("nil", "http://www.w3.org/2001/XMLSchema-instance");
543 if (attribute != null && XmlConvert.ToBoolean(attribute))
544 {
545 reader.ReadElementString();
546 m_fNotNull = false;
547 }
548 else
549 {
551 m_fNotNull = true;
552 }
553 }
554
556 {
557 if (IsNull)
558 {
559 writer.WriteAttributeString("xsi", "nil", "http://www.w3.org/2001/XMLSchema-instance", "true");
560 }
561 else
562 {
563 writer.WriteString(XmlConvert.ToString(m_value));
564 }
565 }
566
568 {
569 return new XmlQualifiedName("short", "http://www.w3.org/2001/XMLSchema");
570 }
571}
static Exception WrongType(Type got, Type expected)
Definition ADP.cs:174
static bool ToBoolean(string s)
static short ToInt16(string s)
static string ToString(bool value)
string? GetAttribute(string name)
virtual string ReadElementString()
Definition XmlReader.cs:667
static readonly SqlBoolean Null
Definition SqlBoolean.cs:21
static SqlInt16 operator^(SqlInt16 x, SqlInt16 y)
Definition SqlInt16.cs:194
static SqlInt16 operator/(SqlInt16 x, SqlInt16 y)
Definition SqlInt16.cs:142
static SqlInt16 OnesComplement(SqlInt16 x)
Definition SqlInt16.cs:350
static SqlInt16 Mod(SqlInt16 x, SqlInt16 y)
Definition SqlInt16.cs:375
static SqlBoolean LessThan(SqlInt16 x, SqlInt16 y)
Definition SqlInt16.cs:410
static SqlBoolean NotEquals(SqlInt16 x, SqlInt16 y)
Definition SqlInt16.cs:405
static SqlInt16 Xor(SqlInt16 x, SqlInt16 y)
Definition SqlInt16.cs:395
static SqlInt16 operator|(SqlInt16 x, SqlInt16 y)
Definition SqlInt16.cs:185
static SqlBoolean GreaterThan(SqlInt16 x, SqlInt16 y)
Definition SqlInt16.cs:415
static SqlInt16 operator*(SqlInt16 x, SqlInt16 y)
Definition SqlInt16.cs:127
static SqlBoolean Equals(SqlInt16 x, SqlInt16 y)
Definition SqlInt16.cs:400
static SqlInt16 Modulus(SqlInt16 x, SqlInt16 y)
Definition SqlInt16.cs:380
static readonly SqlInt16 Zero
Definition SqlInt16.cs:21
static readonly SqlInt16 Null
Definition SqlInt16.cs:19
static SqlBoolean operator>=(SqlInt16 x, SqlInt16 y)
Definition SqlInt16.cs:341
static SqlBoolean operator==(SqlInt16 x, SqlInt16 y)
Definition SqlInt16.cs:300
static readonly SqlInt16 MinValue
Definition SqlInt16.cs:23
static SqlInt16 operator-(SqlInt16 x)
Definition SqlInt16.cs:81
static XmlQualifiedName GetXsdType(XmlSchemaSet schemaSet)
Definition SqlInt16.cs:567
int CompareTo(object? value)
Definition SqlInt16.cs:475
static SqlBoolean operator<(SqlInt16 x, SqlInt16 y)
Definition SqlInt16.cs:314
static SqlInt16 operator&(SqlInt16 x, SqlInt16 y)
Definition SqlInt16.cs:176
static SqlBoolean LessThanOrEqual(SqlInt16 x, SqlInt16 y)
Definition SqlInt16.cs:420
static SqlInt16 operator~(SqlInt16 x)
Definition SqlInt16.cs:90
int CompareTo(SqlInt16 value)
Definition SqlInt16.cs:484
static SqlInt16 operator+(SqlInt16 x, SqlInt16 y)
Definition SqlInt16.cs:99
static SqlInt16 Add(SqlInt16 x, SqlInt16 y)
Definition SqlInt16.cs:355
static SqlInt16 BitwiseOr(SqlInt16 x, SqlInt16 y)
Definition SqlInt16.cs:390
static SqlInt16 Multiply(SqlInt16 x, SqlInt16 y)
Definition SqlInt16.cs:365
static SqlBoolean GreaterThanOrEqual(SqlInt16 x, SqlInt16 y)
Definition SqlInt16.cs:425
static SqlBoolean operator>(SqlInt16 x, SqlInt16 y)
Definition SqlInt16.cs:323
static SqlBoolean operator!=(SqlInt16 x, SqlInt16 y)
Definition SqlInt16.cs:309
static SqlInt16 Parse(string s)
Definition SqlInt16.cs:72
static SqlInt16 BitwiseAnd(SqlInt16 x, SqlInt16 y)
Definition SqlInt16.cs:385
static readonly SqlInt16 MaxValue
Definition SqlInt16.cs:25
override string ToString()
Definition SqlInt16.cs:63
static SqlInt16 Divide(SqlInt16 x, SqlInt16 y)
Definition SqlInt16.cs:370
static SqlInt16 Subtract(SqlInt16 x, SqlInt16 y)
Definition SqlInt16.cs:360
static SqlBoolean operator<=(SqlInt16 x, SqlInt16 y)
Definition SqlInt16.cs:332
override bool Equals([NotNullWhen(true)] object? value)
Definition SqlInt16.cs:509
static SqlInt16 operator%(SqlInt16 x, SqlInt16 y)
Definition SqlInt16.cs:159