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

◆ ConvertTo() [1/2]

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

Reimplemented from System.ComponentModel.TypeConverter.

Definition at line 45 of file UriTypeConverter.cs.

46 {
47 if (destinationType == null)
48 {
49 throw new ArgumentNullException("destinationType");
50 }
51 if (value is Uri uri)
52 {
53 if (destinationType == typeof(InstanceDescriptor))
54 {
55 ConstructorInfo constructor = typeof(Uri).GetConstructor(BindingFlags.Instance | BindingFlags.Public, null, new Type[2]
56 {
57 typeof(string),
58 typeof(UriKind)
59 }, null);
60 return new InstanceDescriptor(constructor, new object[2]
61 {
62 uri.OriginalString,
63 GetUriKind(uri)
64 });
65 }
66 if (destinationType == typeof(string))
67 {
68 return uri.OriginalString;
69 }
70 if (destinationType == typeof(Uri))
71 {
72 return new Uri(uri.OriginalString, GetUriKind(uri));
73 }
74 }
75 throw GetConvertToException(value, destinationType);
76 }
Exception GetConvertToException(object? value, Type destinationType)
static UriKind GetUriKind(Uri uri)

References System.ComponentModel.TypeConverter.GetConvertToException(), System.UriTypeConverter.GetUriKind(), and System.value.