Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ CreateSaturating< TOther >()

static nuint INumber< UIntPtr >. System.UIntPtr.CreateSaturating< TOther > ( TOther value)
inlinestatic

Definition at line 539 of file UIntPtr.cs.

540 {
541 if (typeof(TOther) == typeof(byte))
542 {
543 return (byte)(object)value;
544 }
545 if (typeof(TOther) == typeof(char))
546 {
547 return (char)(object)value;
548 }
549 if (typeof(TOther) == typeof(decimal))
550 {
551 decimal num = (decimal)(object)value;
552 if (!(num > (decimal)(ulong)MaxValue))
553 {
554 if (!(num < 0m))
555 {
556 return (nuint)(ulong)num;
557 }
558 return MinValue;
559 }
560 return MaxValue;
561 }
562 if (typeof(TOther) == typeof(double))
563 {
564 double num2 = (double)(object)value;
565 if (!(num2 > (double)(nint)(nuint)MaxValue))
566 {
567 if (!(num2 < 0.0))
568 {
569 return (nuint)num2;
570 }
571 return MinValue;
572 }
573 return MaxValue;
574 }
575 if (typeof(TOther) == typeof(short))
576 {
577 short num3 = (short)(object)value;
578 if (num3 >= 0)
579 {
580 return (nuint)num3;
581 }
582 return MinValue;
583 }
584 if (typeof(TOther) == typeof(int))
585 {
586 int num4 = (int)(object)value;
587 if (num4 >= 0)
588 {
589 return (nuint)num4;
590 }
591 return MinValue;
592 }
593 if (typeof(TOther) == typeof(long))
594 {
595 long num5 = (long)(object)value;
596 if (Size == 4)
597 {
598 }
599 if (num5 >= 0)
600 {
601 return (nuint)num5;
602 }
603 return MinValue;
604 }
605 if (typeof(TOther) == typeof(IntPtr))
606 {
607 IntPtr intPtr = (IntPtr)(object)value;
608 if ((nint)intPtr >= 0)
609 {
610 return (nuint)(nint)intPtr;
611 }
612 return MinValue;
613 }
614 if (typeof(TOther) == typeof(sbyte))
615 {
616 sbyte b = (sbyte)(object)value;
617 if (b >= 0)
618 {
619 return (nuint)b;
620 }
621 return MinValue;
622 }
623 if (typeof(TOther) == typeof(float))
624 {
625 float num6 = (float)(object)value;
626 if (!(num6 > (float)(nint)(nuint)MaxValue))
627 {
628 if (!(num6 < 0f))
629 {
630 return (nuint)num6;
631 }
632 return MinValue;
633 }
634 return MaxValue;
635 }
636 if (typeof(TOther) == typeof(ushort))
637 {
638 return (ushort)(object)value;
639 }
640 if (typeof(TOther) == typeof(uint))
641 {
642 return (uint)(object)value;
643 }
644 if (typeof(TOther) == typeof(ulong))
645 {
646 ulong num7 = (ulong)(object)value;
647 if (num7 <= (nuint)MaxValue)
648 {
649 return (nuint)num7;
650 }
651 return MaxValue;
652 }
653 if (typeof(TOther) == typeof(UIntPtr))
654 {
655 return (UIntPtr)(object)value;
656 }
657 ThrowHelper.ThrowNotSupportedException();
658 return 0u;
659 }
static UIntPtr MaxValue
Definition UIntPtr.cs:31
static int Size
Definition UIntPtr.cs:22
static UIntPtr MinValue
Definition UIntPtr.cs:40
unsafe UIntPtr(uint value)
Definition UIntPtr.cs:67

References System.Runtime.Serialization.Dictionary, System.UIntPtr.MaxValue, System.UIntPtr.MinValue, System.UIntPtr.Size, System.ThrowHelper.ThrowNotSupportedException(), and System.value.