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

◆ ChangeType() [1/2]

override object System.OleAutBinder.ChangeType ( object value,
Type type,
CultureInfo cultureInfo )
inline

Definition at line 9 of file OleAutBinder.cs.

10 {
12 if (cultureInfo == null)
13 {
14 cultureInfo = CultureInfo.CurrentCulture;
15 }
16 if (type.IsByRef)
17 {
18 type = type.GetElementType();
19 }
20 if (!type.IsPrimitive && type.IsInstanceOfType(value))
21 {
22 return value;
23 }
24 Type type2 = value.GetType();
25 if (type.IsEnum && type2.IsPrimitive)
26 {
27 return Enum.Parse(type, value.ToString());
28 }
29 try
30 {
31 return OAVariantLib.ChangeType(source, type, 16, cultureInfo).ToObject();
32 }
33 catch (NotSupportedException)
34 {
35 throw new COMException(SR.Interop_COM_TypeMismatch, -2147352571);
36 }
37 }
static Variant ChangeType(Variant source, Type targetClass, short options, CultureInfo culture)
static CultureInfo CurrentCulture

References Microsoft.Win32.OAVariantLib.ChangeType(), System.Globalization.CultureInfo.CurrentCulture, System.Type.GetType(), System.SR.Interop_COM_TypeMismatch, System.Type.IsPrimitive, System.Enum.Parse(), System.source, System.type, and System.value.