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

◆ IsValid() [1/2]

override bool System.ComponentModel.DataAnnotations.RangeAttribute.IsValid ( object? value)
inlinevirtual

Reimplemented from System.ComponentModel.DataAnnotations.ValidationAttribute.

Definition at line 58 of file RangeAttribute.cs.

59 {
61 if (value != null)
62 {
63 string obj = value as string;
64 if (obj == null || obj.Length != 0)
65 {
66 object obj2;
67 try
68 {
69 obj2 = Conversion(value);
70 }
71 catch (FormatException)
72 {
73 return false;
74 }
75 catch (InvalidCastException)
76 {
77 return false;
78 }
79 catch (NotSupportedException)
80 {
81 return false;
82 }
83 IComparable comparable = (IComparable)Minimum;
84 IComparable comparable2 = (IComparable)Maximum;
85 if (comparable.CompareTo(obj2) <= 0)
86 {
87 return comparable2.CompareTo(obj2) >= 0;
88 }
89 return false;
90 }
91 }
92 return true;
93 }

References System.comparable, System.IComparable< in T >.CompareTo(), System.ComponentModel.DataAnnotations.RangeAttribute.Conversion, System.ComponentModel.DataAnnotations.RangeAttribute.Maximum, System.ComponentModel.DataAnnotations.RangeAttribute.Minimum, System.obj, System.ComponentModel.DataAnnotations.RangeAttribute.SetupConversion(), and System.value.