Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
OAVariantLib.cs
Go to the documentation of this file.
1using System;
5
6namespace Microsoft.Win32;
7
8internal static class OAVariantLib
9{
10 internal static readonly Type[] ClassTypes = new Type[23]
11 {
12 typeof(Empty),
13 typeof(void),
14 typeof(bool),
15 typeof(char),
16 typeof(sbyte),
17 typeof(byte),
18 typeof(short),
19 typeof(ushort),
20 typeof(int),
21 typeof(uint),
22 typeof(long),
23 typeof(ulong),
24 typeof(float),
25 typeof(double),
26 typeof(string),
27 typeof(void),
28 typeof(DateTime),
29 typeof(TimeSpan),
30 typeof(object),
31 typeof(decimal),
32 null,
33 typeof(Missing),
34 typeof(DBNull)
35 };
36
37 internal static Variant ChangeType(Variant source, Type targetClass, short options, CultureInfo culture)
38 {
39 if (targetClass == null)
40 {
41 throw new ArgumentNullException("targetClass");
42 }
43 if (culture == null)
44 {
45 throw new ArgumentNullException("culture");
46 }
47 Variant result = default(Variant);
48 ChangeTypeEx(ref result, ref source, culture.LCID, targetClass.TypeHandle.Value, GetCVTypeFromClass(targetClass), options);
49 return result;
50 }
51
52 private static int GetCVTypeFromClass(Type ctype)
53 {
54 int num = -1;
55 for (int i = 0; i < ClassTypes.Length; i++)
56 {
57 if (ctype.Equals(ClassTypes[i]))
58 {
59 num = i;
60 break;
61 }
62 }
63 if (num == -1)
64 {
65 num = 18;
66 }
67 return num;
68 }
69
70 [MethodImpl(MethodImplOptions.InternalCall)]
71 private static extern void ChangeTypeEx(ref Variant result, ref Variant source, int lcid, IntPtr typeHandle, int cvType, short flags);
72}
static void ChangeTypeEx(ref Variant result, ref Variant source, int lcid, IntPtr typeHandle, int cvType, short flags)
static readonly Type[] ClassTypes
static int GetCVTypeFromClass(Type ctype)
static Variant ChangeType(Variant source, Type targetClass, short options, CultureInfo culture)
override bool Equals(object? o)
Definition Type.cs:1113
virtual RuntimeTypeHandle TypeHandle
Definition Type.cs:286