Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
SqlInt64.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 long m_value;
18
19 public static readonly SqlInt64 Null = new SqlInt64(fNull: true);
20
21 public static readonly SqlInt64 Zero = new SqlInt64(0L);
22
23 public static readonly SqlInt64 MinValue = new SqlInt64(long.MinValue);
24
25 public static readonly SqlInt64 MaxValue = new SqlInt64(long.MaxValue);
26
27 public bool IsNull => !m_fNotNull;
28
29 public long Value
30 {
31 get
32 {
33 if (m_fNotNull)
34 {
35 return m_value;
36 }
37 throw new SqlNullValueException();
38 }
39 }
40
41 private SqlInt64(bool fNull)
42 {
43 m_fNotNull = false;
44 m_value = 0L;
45 }
46
47 public SqlInt64(long value)
48 {
49 m_value = value;
50 m_fNotNull = true;
51 }
52
53 public static implicit operator SqlInt64(long x)
54 {
55 return new SqlInt64(x);
56 }
57
58 public static explicit operator long(SqlInt64 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 SqlInt64 Parse(string s)
73 {
75 {
76 return Null;
77 }
78 return new SqlInt64(long.Parse(s, null));
79 }
80
81 public static SqlInt64 operator -(SqlInt64 x)
82 {
83 if (!x.IsNull)
84 {
85 return new SqlInt64(-x.m_value);
86 }
87 return Null;
88 }
89
90 public static SqlInt64 operator ~(SqlInt64 x)
91 {
92 if (!x.IsNull)
93 {
94 return new SqlInt64(~x.m_value);
95 }
96 return Null;
97 }
98
100 {
101 if (x.IsNull || y.IsNull)
102 {
103 return Null;
104 }
105 long num = x.m_value + y.m_value;
106 if (SameSignLong(x.m_value, y.m_value) && !SameSignLong(x.m_value, num))
107 {
109 }
110 return new SqlInt64(num);
111 }
112
114 {
115 if (x.IsNull || y.IsNull)
116 {
117 return Null;
118 }
119 long num = x.m_value - y.m_value;
120 if (!SameSignLong(x.m_value, y.m_value) && SameSignLong(y.m_value, num))
121 {
123 }
124 return new SqlInt64(num);
125 }
126
128 {
129 if (x.IsNull || y.IsNull)
130 {
131 return Null;
132 }
133 bool flag = false;
134 long num = x.m_value;
135 long num2 = y.m_value;
136 long num3 = 0L;
137 if (num < 0)
138 {
139 flag = true;
140 num = -num;
141 }
142 if (num2 < 0)
143 {
144 flag = !flag;
145 num2 = -num2;
146 }
147 long num4 = num & 0xFFFFFFFFu;
148 long num5 = (num >> 32) & 0xFFFFFFFFu;
149 long num6 = num2 & 0xFFFFFFFFu;
150 long num7 = (num2 >> 32) & 0xFFFFFFFFu;
151 if (num5 != 0L && num7 != 0L)
152 {
154 }
155 long num8 = num4 * num6;
156 if (num8 < 0)
157 {
159 }
160 if (num5 != 0L)
161 {
162 num3 = num5 * num6;
164 {
166 }
167 }
168 else if (num7 != 0L)
169 {
170 num3 = num4 * num7;
172 {
174 }
175 }
176 num8 += num3 << 32;
177 if (num8 < 0)
178 {
180 }
181 if (flag)
182 {
183 num8 = -num8;
184 }
185 return new SqlInt64(num8);
186 }
187
189 {
190 if (x.IsNull || y.IsNull)
191 {
192 return Null;
193 }
194 if (y.m_value != 0L)
195 {
196 if (x.m_value == long.MinValue && y.m_value == -1)
197 {
199 }
200 return new SqlInt64(x.m_value / y.m_value);
201 }
203 }
204
206 {
207 if (x.IsNull || y.IsNull)
208 {
209 return Null;
210 }
211 if (y.m_value != 0L)
212 {
213 if (x.m_value == long.MinValue && y.m_value == -1)
214 {
216 }
217 return new SqlInt64(x.m_value % y.m_value);
218 }
220 }
221
223 {
224 if (!x.IsNull && !y.IsNull)
225 {
226 return new SqlInt64(x.m_value & y.m_value);
227 }
228 return Null;
229 }
230
232 {
233 if (!x.IsNull && !y.IsNull)
234 {
235 return new SqlInt64(x.m_value | y.m_value);
236 }
237 return Null;
238 }
239
241 {
242 if (!x.IsNull && !y.IsNull)
243 {
244 return new SqlInt64(x.m_value ^ y.m_value);
245 }
246 return Null;
247 }
248
249 public static explicit operator SqlInt64(SqlBoolean x)
250 {
251 if (!x.IsNull)
252 {
253 return new SqlInt64(x.ByteValue);
254 }
255 return Null;
256 }
257
258 public static implicit operator SqlInt64(SqlByte x)
259 {
260 if (!x.IsNull)
261 {
262 return new SqlInt64(x.Value);
263 }
264 return Null;
265 }
266
267 public static implicit operator SqlInt64(SqlInt16 x)
268 {
269 if (!x.IsNull)
270 {
271 return new SqlInt64(x.Value);
272 }
273 return Null;
274 }
275
276 public static implicit operator SqlInt64(SqlInt32 x)
277 {
278 if (!x.IsNull)
279 {
280 return new SqlInt64(x.Value);
281 }
282 return Null;
283 }
284
285 public static explicit operator SqlInt64(SqlSingle x)
286 {
287 if (x.IsNull)
288 {
289 return Null;
290 }
291 float value = x.Value;
292 if (value > 9.223372E+18f || value < -9.223372E+18f)
293 {
295 }
296 return new SqlInt64((long)value);
297 }
298
299 public static explicit operator SqlInt64(SqlDouble x)
300 {
301 if (x.IsNull)
302 {
303 return Null;
304 }
305 double value = x.Value;
306 if (value > 9.223372036854776E+18 || value < -9.223372036854776E+18)
307 {
309 }
310 return new SqlInt64((long)value);
311 }
312
313 public static explicit operator SqlInt64(SqlMoney x)
314 {
315 if (!x.IsNull)
316 {
317 return new SqlInt64(x.ToInt64());
318 }
319 return Null;
320 }
321
322 public static explicit operator SqlInt64(SqlDecimal x)
323 {
324 if (x.IsNull)
325 {
326 return Null;
327 }
329 sqlDecimal.AdjustScale(-sqlDecimal._bScale, fRound: false);
330 if (sqlDecimal._bLen > 2)
331 {
333 }
334 long num2;
335 if (sqlDecimal._bLen == 2)
336 {
337 ulong num = SqlDecimal.DWL(sqlDecimal._data1, sqlDecimal._data2);
338 if (num > long.MaxValue && (sqlDecimal.IsPositive || num != 9223372036854775808uL))
339 {
341 }
342 num2 = (long)num;
343 }
344 else
345 {
346 num2 = sqlDecimal._data1;
347 }
348 if (!sqlDecimal.IsPositive)
349 {
350 num2 = -num2;
351 }
352 return new SqlInt64(num2);
353 }
354
355 public static explicit operator SqlInt64(SqlString x)
356 {
357 if (!x.IsNull)
358 {
359 return new SqlInt64(long.Parse(x.Value, null));
360 }
361 return Null;
362 }
363
364 private static bool SameSignLong(long x, long y)
365 {
366 return ((x ^ y) & long.MinValue) == 0;
367 }
368
370 {
371 if (!x.IsNull && !y.IsNull)
372 {
373 return new SqlBoolean(x.m_value == y.m_value);
374 }
375 return SqlBoolean.Null;
376 }
377
379 {
380 return !(x == y);
381 }
382
384 {
385 if (!x.IsNull && !y.IsNull)
386 {
387 return new SqlBoolean(x.m_value < y.m_value);
388 }
389 return SqlBoolean.Null;
390 }
391
393 {
394 if (!x.IsNull && !y.IsNull)
395 {
396 return new SqlBoolean(x.m_value > y.m_value);
397 }
398 return SqlBoolean.Null;
399 }
400
402 {
403 if (!x.IsNull && !y.IsNull)
404 {
405 return new SqlBoolean(x.m_value <= y.m_value);
406 }
407 return SqlBoolean.Null;
408 }
409
411 {
412 if (!x.IsNull && !y.IsNull)
413 {
414 return new SqlBoolean(x.m_value >= y.m_value);
415 }
416 return SqlBoolean.Null;
417 }
418
420 {
421 return ~x;
422 }
423
424 public static SqlInt64 Add(SqlInt64 x, SqlInt64 y)
425 {
426 return x + y;
427 }
428
429 public static SqlInt64 Subtract(SqlInt64 x, SqlInt64 y)
430 {
431 return x - y;
432 }
433
434 public static SqlInt64 Multiply(SqlInt64 x, SqlInt64 y)
435 {
436 return x * y;
437 }
438
439 public static SqlInt64 Divide(SqlInt64 x, SqlInt64 y)
440 {
441 return x / y;
442 }
443
444 public static SqlInt64 Mod(SqlInt64 x, SqlInt64 y)
445 {
446 return x % y;
447 }
448
449 public static SqlInt64 Modulus(SqlInt64 x, SqlInt64 y)
450 {
451 return x % y;
452 }
453
455 {
456 return x & y;
457 }
458
460 {
461 return x | y;
462 }
463
464 public static SqlInt64 Xor(SqlInt64 x, SqlInt64 y)
465 {
466 return x ^ y;
467 }
468
469 public static SqlBoolean Equals(SqlInt64 x, SqlInt64 y)
470 {
471 return x == y;
472 }
473
475 {
476 return x != y;
477 }
478
480 {
481 return x < y;
482 }
483
485 {
486 return x > y;
487 }
488
490 {
491 return x <= y;
492 }
493
495 {
496 return x >= y;
497 }
498
500 {
501 return (SqlBoolean)this;
502 }
503
505 {
506 return (SqlByte)this;
507 }
508
510 {
511 return this;
512 }
513
515 {
516 return (SqlInt16)this;
517 }
518
520 {
521 return (SqlInt32)this;
522 }
523
525 {
526 return this;
527 }
528
530 {
531 return this;
532 }
533
535 {
536 return this;
537 }
538
540 {
541 return (SqlString)this;
542 }
543
544 public int CompareTo(object? value)
545 {
547 {
548 return CompareTo(value2);
549 }
550 throw ADP.WrongType(value.GetType(), typeof(SqlInt64));
551 }
552
554 {
555 if (IsNull)
556 {
557 if (!value.IsNull)
558 {
559 return -1;
560 }
561 return 0;
562 }
563 if (value.IsNull)
564 {
565 return 1;
566 }
567 if (this < value)
568 {
569 return -1;
570 }
571 if (this > value)
572 {
573 return 1;
574 }
575 return 0;
576 }
577
578 public override bool Equals([NotNullWhen(true)] object? value)
579 {
580 if (!(value is SqlInt64 sqlInt))
581 {
582 return false;
583 }
584 if (sqlInt.IsNull || IsNull)
585 {
586 if (sqlInt.IsNull)
587 {
588 return IsNull;
589 }
590 return false;
591 }
592 return (this == sqlInt).Value;
593 }
594
595 public override int GetHashCode()
596 {
597 if (!IsNull)
598 {
599 return Value.GetHashCode();
600 }
601 return 0;
602 }
603
605 {
606 return null;
607 }
608
610 {
611 string attribute = reader.GetAttribute("nil", "http://www.w3.org/2001/XMLSchema-instance");
612 if (attribute != null && XmlConvert.ToBoolean(attribute))
613 {
614 reader.ReadElementString();
615 m_fNotNull = false;
616 }
617 else
618 {
620 m_fNotNull = true;
621 }
622 }
623
625 {
626 if (IsNull)
627 {
628 writer.WriteAttributeString("xsi", "nil", "http://www.w3.org/2001/XMLSchema-instance", "true");
629 }
630 else
631 {
632 writer.WriteString(XmlConvert.ToString(m_value));
633 }
634 }
635
637 {
638 return new XmlQualifiedName("long", "http://www.w3.org/2001/XMLSchema");
639 }
640}
static Exception WrongType(Type got, Type expected)
Definition ADP.cs:174
static string ConversionOverflowMessage
static bool ToBoolean(string s)
static string ToString(bool value)
static long ToInt64(string s)
string? GetAttribute(string name)
virtual string ReadElementString()
Definition XmlReader.cs:667
static readonly SqlBoolean Null
Definition SqlBoolean.cs:21
static ulong DWL(uint lo, uint hi)
void AdjustScale(int digits, bool fRound)
static readonly SqlInt64 Null
Definition SqlInt64.cs:19
static readonly SqlInt64 MinValue
Definition SqlInt64.cs:23
static SqlBoolean operator==(SqlInt64 x, SqlInt64 y)
Definition SqlInt64.cs:369
static SqlInt64 operator/(SqlInt64 x, SqlInt64 y)
Definition SqlInt64.cs:188
static SqlInt64 Modulus(SqlInt64 x, SqlInt64 y)
Definition SqlInt64.cs:449
static SqlInt64 Parse(string s)
Definition SqlInt64.cs:72
static SqlInt64 Mod(SqlInt64 x, SqlInt64 y)
Definition SqlInt64.cs:444
static SqlInt64 operator^(SqlInt64 x, SqlInt64 y)
Definition SqlInt64.cs:240
static SqlInt64 BitwiseAnd(SqlInt64 x, SqlInt64 y)
Definition SqlInt64.cs:454
override string ToString()
Definition SqlInt64.cs:63
static SqlInt64 Add(SqlInt64 x, SqlInt64 y)
Definition SqlInt64.cs:424
static readonly SqlInt64 MaxValue
Definition SqlInt64.cs:25
static SqlInt64 operator|(SqlInt64 x, SqlInt64 y)
Definition SqlInt64.cs:231
static SqlInt64 Divide(SqlInt64 x, SqlInt64 y)
Definition SqlInt64.cs:439
static SqlBoolean GreaterThanOrEqual(SqlInt64 x, SqlInt64 y)
Definition SqlInt64.cs:494
static SqlInt64 Multiply(SqlInt64 x, SqlInt64 y)
Definition SqlInt64.cs:434
static SqlBoolean NotEquals(SqlInt64 x, SqlInt64 y)
Definition SqlInt64.cs:474
static SqlInt64 operator-(SqlInt64 x)
Definition SqlInt64.cs:81
static SqlBoolean Equals(SqlInt64 x, SqlInt64 y)
Definition SqlInt64.cs:469
static SqlBoolean operator!=(SqlInt64 x, SqlInt64 y)
Definition SqlInt64.cs:378
static SqlBoolean operator>=(SqlInt64 x, SqlInt64 y)
Definition SqlInt64.cs:410
static SqlInt64 operator*(SqlInt64 x, SqlInt64 y)
Definition SqlInt64.cs:127
static SqlInt64 operator~(SqlInt64 x)
Definition SqlInt64.cs:90
static SqlInt64 operator&(SqlInt64 x, SqlInt64 y)
Definition SqlInt64.cs:222
static SqlBoolean GreaterThan(SqlInt64 x, SqlInt64 y)
Definition SqlInt64.cs:484
static SqlInt64 BitwiseOr(SqlInt64 x, SqlInt64 y)
Definition SqlInt64.cs:459
static XmlQualifiedName GetXsdType(XmlSchemaSet schemaSet)
Definition SqlInt64.cs:636
static SqlInt64 operator%(SqlInt64 x, SqlInt64 y)
Definition SqlInt64.cs:205
int CompareTo(SqlInt64 value)
Definition SqlInt64.cs:553
override bool Equals([NotNullWhen(true)] object? value)
Definition SqlInt64.cs:578
static SqlInt64 OnesComplement(SqlInt64 x)
Definition SqlInt64.cs:419
static SqlBoolean operator<=(SqlInt64 x, SqlInt64 y)
Definition SqlInt64.cs:401
static SqlBoolean LessThanOrEqual(SqlInt64 x, SqlInt64 y)
Definition SqlInt64.cs:489
static bool SameSignLong(long x, long y)
Definition SqlInt64.cs:364
static readonly SqlInt64 Zero
Definition SqlInt64.cs:21
static SqlInt64 Subtract(SqlInt64 x, SqlInt64 y)
Definition SqlInt64.cs:429
int CompareTo(object? value)
Definition SqlInt64.cs:544
static SqlInt64 Xor(SqlInt64 x, SqlInt64 y)
Definition SqlInt64.cs:464
static SqlInt64 operator+(SqlInt64 x, SqlInt64 y)
Definition SqlInt64.cs:99
static SqlBoolean LessThan(SqlInt64 x, SqlInt64 y)
Definition SqlInt64.cs:479
static SqlBoolean operator>(SqlInt64 x, SqlInt64 y)
Definition SqlInt64.cs:392
static SqlBoolean operator<(SqlInt64 x, SqlInt64 y)
Definition SqlInt64.cs:383