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

◆ ConvertTo() [1/2]

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

Reimplemented from System.ComponentModel.TypeConverter.

Definition at line 62 of file RectangleConverter.cs.

63 {
64 if (destinationType == null)
65 {
66 throw new ArgumentNullException("destinationType");
67 }
68 if (value is Rectangle rectangle)
69 {
70 if (destinationType == typeof(string))
71 {
72 if (culture == null)
73 {
75 }
76 string separator = culture.TextInfo.ListSeparator + " ";
77 TypeConverter converterTrimUnsafe = TypeDescriptor.GetConverterTrimUnsafe(typeof(int));
78 string[] value2 = new string[4]
79 {
80 converterTrimUnsafe.ConvertToString(context, culture, rectangle.X),
81 converterTrimUnsafe.ConvertToString(context, culture, rectangle.Y),
82 converterTrimUnsafe.ConvertToString(context, culture, rectangle.Width),
83 converterTrimUnsafe.ConvertToString(context, culture, rectangle.Height)
84 };
85 return string.Join(separator, value2);
86 }
87 if (destinationType == typeof(InstanceDescriptor))
88 {
89 ConstructorInfo constructor = typeof(Rectangle).GetConstructor(new Type[4]
90 {
91 typeof(int),
92 typeof(int),
93 typeof(int),
94 typeof(int)
95 });
96 if (constructor != null)
97 {
98 return new InstanceDescriptor(constructor, new object[4] { rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height });
99 }
100 }
101 }
102 return base.ConvertTo(context, culture, value, destinationType);
103 }
string? ConvertToString(object? value)
static TypeConverter GetConverterTrimUnsafe([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type type)
static CultureInfo CurrentCulture

References System.ComponentModel.TypeConverter.ConvertToString(), System.culture, System.Globalization.CultureInfo.CurrentCulture, System.ComponentModel.TypeDescriptor.GetConverterTrimUnsafe(), and System.value.