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

◆ ConvertFrom() [1/2]

override? object System.Drawing.RectangleConverter.ConvertFrom ( ITypeDescriptorContext? context,
CultureInfo? culture,
object value )
inlinevirtual

Reimplemented from System.ComponentModel.TypeConverter.

Definition at line 32 of file RectangleConverter.cs.

33 {
34 if (value is string text)
35 {
36 string text2 = text.Trim();
37 if (text2.Length == 0)
38 {
39 return null;
40 }
41 if (culture == null)
42 {
44 }
45 char separator = culture.TextInfo.ListSeparator[0];
46 string[] array = text2.Split(separator);
47 int[] array2 = new int[array.Length];
48 TypeConverter converterTrimUnsafe = TypeDescriptor.GetConverterTrimUnsafe(typeof(int));
49 for (int i = 0; i < array2.Length; i++)
50 {
51 array2[i] = (int)converterTrimUnsafe.ConvertFromString(context, culture, array[i]);
52 }
53 if (array2.Length != 4)
54 {
55 throw new ArgumentException(System.SR.Format(System.SR.TextParseFailedFormat, "text", text2, "x, y, width, height"));
56 }
57 return new Rectangle(array2[0], array2[1], array2[2], array2[3]);
58 }
59 return base.ConvertFrom(context, culture, value);
60 }
object? ConvertFromString(string text)
static TypeConverter GetConverterTrimUnsafe([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type type)
static CultureInfo CurrentCulture
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
static string TextParseFailedFormat
Definition SR.cs:58
Definition SR.cs:7

References System.array, System.ComponentModel.TypeConverter.ConvertFromString(), System.culture, System.Globalization.CultureInfo.CurrentCulture, System.SR.Format(), System.ComponentModel.TypeDescriptor.GetConverterTrimUnsafe(), System.text, System.SR.TextParseFailedFormat, and System.value.