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

◆ FindMostSpecificType()

static int System.DefaultBinder.FindMostSpecificType ( Type c1,
Type c2,
Type t )
inlinestaticprivateinherited

Definition at line 782 of file DefaultBinder.cs.

783 {
784 if (c1 == c2)
785 {
786 return 0;
787 }
788 if (t is SignatureType pattern)
789 {
790 if (pattern.MatchesExactly(c1))
791 {
792 return 1;
793 }
794 if (pattern.MatchesExactly(c2))
795 {
796 return 2;
797 }
798 }
799 else
800 {
801 if (c1 == t)
802 {
803 return 1;
804 }
805 if (c2 == t)
806 {
807 return 2;
808 }
809 }
810 if (c1.IsByRef || c2.IsByRef)
811 {
812 if (c1.IsByRef && c2.IsByRef)
813 {
814 c1 = c1.GetElementType();
815 c2 = c2.GetElementType();
816 }
817 else if (c1.IsByRef)
818 {
819 if (c1.GetElementType() == c2)
820 {
821 return 2;
822 }
823 c1 = c1.GetElementType();
824 }
825 else
826 {
827 if (c2.GetElementType() == c1)
828 {
829 return 1;
830 }
831 c2 = c2.GetElementType();
832 }
833 }
834 bool flag;
835 bool flag2;
836 if (c1.IsPrimitive && c2.IsPrimitive)
837 {
838 flag = CanChangePrimitive(c2, c1);
839 flag2 = CanChangePrimitive(c1, c2);
840 }
841 else
842 {
843 flag = c1.IsAssignableFrom(c2);
844 flag2 = c2.IsAssignableFrom(c1);
845 }
846 if (flag == flag2)
847 {
848 return 0;
849 }
850 if (flag)
851 {
852 return 2;
853 }
854 return 1;
855 }
static bool CanChangePrimitive(Type source, Type target)

References System.DefaultBinder.CanChangePrimitive(), System.Type.GetElementType(), System.Type.IsAssignableFrom(), System.Type.IsByRef, and System.Type.IsPrimitive.

Referenced by System.DefaultBinder.FindMostSpecific(), and System.DefaultBinder.SelectProperty().