Terraria
v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
EnumeratorToEnumVariantMarshaler.cs
Go to the documentation of this file.
1
using
System.Collections
;
2
using
System.Runtime.InteropServices.ComTypes
;
3
using
System.Runtime.Versioning
;
4
5
namespace
System.Runtime.InteropServices.CustomMarshalers
;
6
7
[SupportedOSPlatform(
"windows"
)]
8
internal
sealed
class
EnumeratorToEnumVariantMarshaler
:
ICustomMarshaler
9
{
10
private
static
readonly
EnumeratorToEnumVariantMarshaler
s_enumeratorToEnumVariantMarshaler
=
new
EnumeratorToEnumVariantMarshaler
();
11
12
public
static
ICustomMarshaler
GetInstance
(
string
cookie)
13
{
14
return
s_enumeratorToEnumVariantMarshaler
;
15
}
16
17
private
EnumeratorToEnumVariantMarshaler
()
18
{
19
}
20
21
public
void
CleanUpManagedData
(
object
ManagedObj)
22
{
23
}
24
25
public
void
CleanUpNativeData
(
IntPtr
pNativeData)
26
{
27
Marshal
.
Release
(pNativeData);
28
}
29
30
public
int
GetNativeDataSize
()
31
{
32
return
-1;
33
}
34
35
public
IntPtr
MarshalManagedToNative
(
object
ManagedObj)
36
{
37
if
(ManagedObj ==
null
)
38
{
39
throw
new
ArgumentNullException
(
"ManagedObj"
);
40
}
41
if
(ManagedObj is
EnumeratorViewOfEnumVariant
enumeratorViewOfEnumVariant)
42
{
43
return
Marshal
.
GetComInterfaceForObject
<object,
IEnumVARIANT
>(enumeratorViewOfEnumVariant.GetUnderlyingObject());
44
}
45
EnumVariantViewOfEnumerator
o =
new
EnumVariantViewOfEnumerator
((
System
.
Collections
.
IEnumerator
)ManagedObj);
46
return
Marshal
.
GetComInterfaceForObject
<
EnumVariantViewOfEnumerator
,
IEnumVARIANT
>(o);
47
}
48
49
public
object
MarshalNativeToManaged
(
IntPtr
pNativeData)
50
{
51
if
(pNativeData ==
IntPtr
.
Zero
)
52
{
53
throw
new
ArgumentNullException
(
"pNativeData"
);
54
}
55
object
objectForIUnknown =
Marshal
.
GetObjectForIUnknown
(pNativeData);
56
if
(!objectForIUnknown.GetType().IsCOMObject)
57
{
58
if
(objectForIUnknown is
EnumVariantViewOfEnumerator
enumVariantViewOfEnumerator)
59
{
60
return
enumVariantViewOfEnumerator.Enumerator;
61
}
62
return
objectForIUnknown as
System
.
Collections
.
IEnumerator
;
63
}
64
return
ComDataHelpers
.GetOrCreateManagedViewFromComData(objectForIUnknown, (
IEnumVARIANT
var) =>
new
EnumeratorViewOfEnumVariant
(var));
65
}
66
}
System.ArgumentNullException
Definition
ArgumentNullException.cs:10
System.Runtime.InteropServices.CustomMarshalers.ComDataHelpers
Definition
ComDataHelpers.cs:6
System.Runtime.InteropServices.CustomMarshalers.EnumVariantViewOfEnumerator
Definition
EnumVariantViewOfEnumerator.cs:7
System.Runtime.InteropServices.CustomMarshalers.EnumeratorToEnumVariantMarshaler.GetInstance
static ICustomMarshaler GetInstance(string cookie)
Definition
EnumeratorToEnumVariantMarshaler.cs:12
System.Runtime.InteropServices.CustomMarshalers.EnumeratorToEnumVariantMarshaler.MarshalNativeToManaged
object MarshalNativeToManaged(IntPtr pNativeData)
Definition
EnumeratorToEnumVariantMarshaler.cs:49
System.Runtime.InteropServices.CustomMarshalers.EnumeratorToEnumVariantMarshaler.s_enumeratorToEnumVariantMarshaler
static readonly EnumeratorToEnumVariantMarshaler s_enumeratorToEnumVariantMarshaler
Definition
EnumeratorToEnumVariantMarshaler.cs:10
System.Runtime.InteropServices.CustomMarshalers.EnumeratorToEnumVariantMarshaler.EnumeratorToEnumVariantMarshaler
EnumeratorToEnumVariantMarshaler()
Definition
EnumeratorToEnumVariantMarshaler.cs:17
System.Runtime.InteropServices.CustomMarshalers.EnumeratorToEnumVariantMarshaler.GetNativeDataSize
int GetNativeDataSize()
Definition
EnumeratorToEnumVariantMarshaler.cs:30
System.Runtime.InteropServices.CustomMarshalers.EnumeratorToEnumVariantMarshaler.MarshalManagedToNative
IntPtr MarshalManagedToNative(object ManagedObj)
Definition
EnumeratorToEnumVariantMarshaler.cs:35
System.Runtime.InteropServices.CustomMarshalers.EnumeratorToEnumVariantMarshaler.CleanUpNativeData
void CleanUpNativeData(IntPtr pNativeData)
Definition
EnumeratorToEnumVariantMarshaler.cs:25
System.Runtime.InteropServices.CustomMarshalers.EnumeratorToEnumVariantMarshaler.CleanUpManagedData
void CleanUpManagedData(object ManagedObj)
Definition
EnumeratorToEnumVariantMarshaler.cs:21
System.Runtime.InteropServices.CustomMarshalers.EnumeratorToEnumVariantMarshaler
Definition
EnumeratorToEnumVariantMarshaler.cs:9
System.Runtime.InteropServices.CustomMarshalers.EnumeratorViewOfEnumVariant
Definition
EnumeratorViewOfEnumVariant.cs:7
System.Runtime.InteropServices.Marshal.GetComInterfaceForObject
static IntPtr GetComInterfaceForObject(object o, Type T)
Definition
Marshal.cs:257
System.Runtime.InteropServices.Marshal.Release
static unsafe int Release(IntPtr pUnk)
Definition
Marshal.cs:766
System.Runtime.InteropServices.Marshal.GetObjectForIUnknown
static object GetObjectForIUnknown(IntPtr pUnk)
Definition
Marshal.cs:295
System.Runtime.InteropServices.Marshal
Definition
Marshal.cs:14
System.Collections.IEnumerator
Definition
IEnumerator.cs:4
System.Runtime.InteropServices.ComTypes.IEnumVARIANT
Definition
IEnumVARIANT.cs:7
System.Runtime.InteropServices.ICustomMarshaler
Definition
ICustomMarshaler.cs:4
System.Collections
Definition
BlockingCollection.cs:8
System.Runtime.InteropServices.ComTypes
Definition
BIND_OPTS.cs:1
System.Runtime.InteropServices.CustomMarshalers
Definition
ComDataHelpers.cs:3
System.Runtime.Versioning
Definition
NonVersionableAttribute.cs:1
System
Definition
BlockingCollection.cs:8
System.IntPtr.Zero
static readonly IntPtr Zero
Definition
IntPtr.cs:18
System.IntPtr
Definition
IntPtr.cs:14
source
System.Private.CoreLib
System.Runtime.InteropServices.CustomMarshalers
EnumeratorToEnumVariantMarshaler.cs
Generated by
1.10.0