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