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

◆ ConvertFrom() [1/2]

override? object System.ComponentModel.EnumConverter.ConvertFrom ( ITypeDescriptorContext? context,
CultureInfo? culture,
object value )
inlinevirtual

Reimplemented from System.ComponentModel.TypeConverter.

Definition at line 51 of file EnumConverter.cs.

52 {
53 if (value is string text)
54 {
55 try
56 {
57 if (text.Contains(','))
58 {
59 bool isUnderlyingTypeUInt = Enum.GetUnderlyingType(EnumType) == typeof(ulong);
60 long num = 0L;
61 string[] array = text.Split(',');
62 string[] array2 = array;
63 foreach (string value2 in array2)
64 {
66 }
67 return Enum.ToObject(EnumType, num);
68 }
69 return Enum.Parse(EnumType, text, ignoreCase: true);
70 }
71 catch (Exception innerException)
72 {
73 throw new FormatException(System.SR.Format(System.SR.ConvertInvalidPrimitive, (string)value, EnumType.Name), innerException);
74 }
75 }
76 if (value is Enum[])
77 {
78 bool isUnderlyingTypeUInt2 = Enum.GetUnderlyingType(EnumType) == typeof(ulong);
79 long num2 = 0L;
80 Enum[] array3 = (Enum[])value;
81 foreach (Enum enumVal in array3)
82 {
84 }
85 return Enum.ToObject(EnumType, num2);
86 }
87 return base.ConvertFrom(context, culture, value);
88 }
static long GetEnumValue(bool isUnderlyingTypeUInt64, Enum enumVal, CultureInfo culture)
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
static string ConvertInvalidPrimitive
Definition SR.cs:20
Definition SR.cs:7

References System.array, System.SR.ConvertInvalidPrimitive, System.culture, System.ComponentModel.EnumConverter.EnumType, System.SR.Format(), System.ComponentModel.EnumConverter.GetEnumValue(), System.Enum.GetUnderlyingType(), System.L, System.Reflection.MemberInfo.Name, System.Enum.Parse(), System.text, System.Enum.ToObject(), and System.value.