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

◆ CreateSaturating< TOther >()

static nint INumber< IntPtr >. System.IntPtr.CreateSaturating< TOther > ( TOther value)
inlinestatic

Definition at line 550 of file IntPtr.cs.

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

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