Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
OleAutBinder.cs
Go to the documentation of this file.
4
5namespace System;
6
7internal sealed class OleAutBinder : DefaultBinder
8{
9 public override object ChangeType(object value, Type type, CultureInfo cultureInfo)
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 }
34 {
35 throw new COMException(SR.Interop_COM_TypeMismatch, -2147352571);
36 }
37 }
38}
static Variant ChangeType(Variant source, Type targetClass, short options, CultureInfo culture)
static object Parse(Type enumType, string value)
Definition Enum.cs:368
static CultureInfo CurrentCulture
override object ChangeType(object value, Type type, CultureInfo cultureInfo)
static string Interop_COM_TypeMismatch
Definition SR.cs:1372
Definition SR.cs:7
static ? Type GetType(string typeName, bool throwOnError, bool ignoreCase)
Definition Type.cs:408
bool IsPrimitive
Definition Type.cs:231