Terraria
v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
OAVariantLib.cs
Go to the documentation of this file.
1
using
System
;
2
using
System.Globalization
;
3
using
System.Reflection
;
4
using
System.Runtime.CompilerServices
;
5
6
namespace
Microsoft.Win32
;
7
8
internal
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
}
Microsoft.Win32.OAVariantLib.ChangeTypeEx
static void ChangeTypeEx(ref Variant result, ref Variant source, int lcid, IntPtr typeHandle, int cvType, short flags)
Microsoft.Win32.OAVariantLib.ClassTypes
static readonly Type[] ClassTypes
Definition
OAVariantLib.cs:10
Microsoft.Win32.OAVariantLib.GetCVTypeFromClass
static int GetCVTypeFromClass(Type ctype)
Definition
OAVariantLib.cs:52
Microsoft.Win32.OAVariantLib.ChangeType
static Variant ChangeType(Variant source, Type targetClass, short options, CultureInfo culture)
Definition
OAVariantLib.cs:37
Microsoft.Win32.OAVariantLib
Definition
OAVariantLib.cs:9
System.ArgumentNullException
Definition
ArgumentNullException.cs:10
System.DBNull
Definition
DBNull.cs:7
System.Empty
Definition
Empty.cs:4
System.Globalization.CultureInfo
Definition
CultureInfo.cs:8
System.Reflection.Missing
Definition
Missing.cs:6
System.Type.Equals
override bool Equals(object? o)
Definition
Type.cs:1113
System.Type.TypeHandle
virtual RuntimeTypeHandle TypeHandle
Definition
Type.cs:286
System.Type
Definition
Type.cs:14
Microsoft.Win32
Definition
SafeProcessHandle.cs:3
System.Globalization
Definition
Calendar.cs:1
System.Reflection
Definition
ICustomTypeProvider.cs:1
System.Runtime.CompilerServices.MethodImplOptions
MethodImplOptions
Definition
MethodImplOptions.cs:5
System.Runtime.CompilerServices
Definition
NullablePublicOnlyAttribute.cs:3
System.ExceptionArgument.source
@ source
System.ExceptionArgument.culture
@ culture
System.ExceptionArgument.options
@ options
System
Definition
BlockingCollection.cs:8
System.DateTime
Definition
DateTime.cs:15
System.IntPtr
Definition
IntPtr.cs:14
System.RuntimeTypeHandle.Value
IntPtr Value
Definition
RuntimeTypeHandle.cs:51
System.TimeSpan
Definition
TimeSpan.cs:10
System.Variant
Definition
Variant.cs:9
source
System.Private.CoreLib
Microsoft.Win32
OAVariantLib.cs
Generated by
1.10.0