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

◆ SetupConversion()

void System.ComponentModel.DataAnnotations.RangeAttribute.SetupConversion ( )
inlineprivate

Definition at line 101 of file RangeAttribute.cs.

102 {
103 if (Conversion != null)
104 {
105 return;
106 }
107 object minimum = Minimum;
108 object maximum = Maximum;
109 if (minimum == null || maximum == null)
110 {
112 }
113 Type type2 = minimum.GetType();
114 if (type2 == typeof(int))
115 {
116 Initialize((int)minimum, (int)maximum, (object v) => Convert.ToInt32(v, CultureInfo.InvariantCulture));
117 return;
118 }
119 if (type2 == typeof(double))
120 {
121 Initialize((double)minimum, (double)maximum, (object v) => Convert.ToDouble(v, CultureInfo.InvariantCulture));
122 return;
123 }
125 if (type == null)
126 {
128 }
129 Type typeFromHandle = typeof(IComparable);
130 if (!typeFromHandle.IsAssignableFrom(type))
131 {
133 }
134 TypeConverter converter = GetOperandTypeConverter();
135 IComparable minimum2 = (IComparable)(ParseLimitsInInvariantCulture ? converter.ConvertFromInvariantString((string)minimum) : converter.ConvertFromString((string)minimum));
136 IComparable maximum2 = (IComparable)(ParseLimitsInInvariantCulture ? converter.ConvertFromInvariantString((string)maximum) : converter.ConvertFromString((string)maximum));
137 Func<object, object> conversion = ((!ConvertValueInInvariantCulture) ? ((Func<object, object>)((object value) => (!(value.GetType() == type)) ? converter.ConvertFrom(value) : value)) : ((Func<object, object>)((object value) => (!(value.GetType() == type)) ? converter.ConvertFrom(null, CultureInfo.InvariantCulture, value) : value)));
138 Initialize(minimum2, maximum2, conversion);
139 }
void Initialize(IComparable minimum, IComparable maximum, Func< object, object > conversion)
static CultureInfo InvariantCulture
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
static string RangeAttribute_Must_Set_Min_And_Max
Definition SR.cs:76
static string RangeAttribute_ArbitraryTypeNotIComparable
Definition SR.cs:72
static string RangeAttribute_Must_Set_Operand_Type
Definition SR.cs:78
Definition SR.cs:7

References System.ComponentModel.DataAnnotations.RangeAttribute.Conversion, System.converter, System.ComponentModel.DataAnnotations.RangeAttribute.ConvertValueInInvariantCulture, System.SR.Format(), System.Type.FullName, System.ComponentModel.DataAnnotations.RangeAttribute.GetOperandTypeConverter(), System.ComponentModel.DataAnnotations.RangeAttribute.Initialize(), System.Globalization.CultureInfo.InvariantCulture, System.Type.IsAssignableFrom(), System.ComponentModel.DataAnnotations.RangeAttribute.Maximum, System.ComponentModel.DataAnnotations.RangeAttribute.Minimum, System.ComponentModel.DataAnnotations.RangeAttribute.OperandType, System.ComponentModel.DataAnnotations.RangeAttribute.ParseLimitsInInvariantCulture, System.SR.RangeAttribute_ArbitraryTypeNotIComparable, System.SR.RangeAttribute_Must_Set_Min_And_Max, System.SR.RangeAttribute_Must_Set_Operand_Type, System.Convert.ToDouble(), System.Convert.ToInt32(), System.type, and System.value.

Referenced by System.ComponentModel.DataAnnotations.RangeAttribute.FormatErrorMessage(), and System.ComponentModel.DataAnnotations.RangeAttribute.IsValid().