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

◆ TryConvertValue()

bool System.ComponentModel.DataAnnotations.CustomValidationAttribute.TryConvertValue ( object value,
out object convertedValue )
inlineprivate

Definition at line 149 of file CustomValidationAttribute.cs.

150 {
151 convertedValue = null;
152 Type firstParameterType = _firstParameterType;
153 if (value == null)
154 {
155 if (firstParameterType.IsValueType && (!firstParameterType.IsGenericType || firstParameterType.GetGenericTypeDefinition() != typeof(Nullable<>)))
156 {
157 return false;
158 }
159 return true;
160 }
161 if (firstParameterType.IsInstanceOfType(value))
162 {
163 convertedValue = value;
164 return true;
165 }
166 try
167 {
168 convertedValue = Convert.ChangeType(value, firstParameterType, CultureInfo.CurrentCulture);
169 return true;
170 }
171 catch (FormatException)
172 {
173 return false;
174 }
175 catch (InvalidCastException)
176 {
177 return false;
178 }
179 catch (NotSupportedException)
180 {
181 return false;
182 }
183 }
static CultureInfo CurrentCulture

References System.ComponentModel.DataAnnotations.CustomValidationAttribute._firstParameterType, System.Convert.ChangeType(), System.Globalization.CultureInfo.CurrentCulture, System.Type.GetGenericTypeDefinition(), System.Type.IsGenericType, System.Type.IsInstanceOfType(), System.Type.IsValueType, and System.value.

Referenced by System.ComponentModel.DataAnnotations.CustomValidationAttribute.IsValid().