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

◆ ConvertFrom() [1/2]

override? object System.ComponentModel.BaseNumberConverter.ConvertFrom ( ITypeDescriptorContext? context,
CultureInfo? culture,
object value )
inlinevirtualinherited

Reimplemented from System.ComponentModel.TypeConverter.

Definition at line 30 of file BaseNumberConverter.cs.

31 {
32 if (value is string text)
33 {
34 string text2 = text.Trim();
35 try
36 {
37 if (AllowHex && text2[0] == '#')
38 {
39 return FromString(text2.Substring(1), 16);
40 }
41 if (AllowHex && (text2.StartsWith("0x", StringComparison.OrdinalIgnoreCase) || text2.StartsWith("&h", StringComparison.OrdinalIgnoreCase)))
42 {
43 return FromString(text2.Substring(2), 16);
44 }
45 if (culture == null)
46 {
48 }
50 return FromString(text2, formatInfo);
51 }
52 catch (Exception innerException)
53 {
54 throw new ArgumentException(System.SR.Format(System.SR.ConvertInvalidPrimitive, text2, TargetType.Name), "value", innerException);
55 }
56 }
57 return base.ConvertFrom(context, culture, value);
58 }
object FromString(string value, int radix)
static CultureInfo CurrentCulture
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
static string ConvertInvalidPrimitive
Definition SR.cs:20
Definition SR.cs:7

References System.ComponentModel.BaseNumberConverter.AllowHex, System.SR.ConvertInvalidPrimitive, System.culture, System.Globalization.CultureInfo.CurrentCulture, System.SR.Format(), System.ComponentModel.BaseNumberConverter.FromString(), System.Globalization.NumberFormatInfo.GetFormat(), System.text, and System.value.