Terraria
v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
ComDataHelpers.cs
Go to the documentation of this file.
1
using
System.Runtime.Versioning
;
2
3
namespace
System.Runtime.InteropServices.CustomMarshalers
;
4
5
internal
static
class
ComDataHelpers
6
{
7
[SupportedOSPlatform(
"windows"
)]
8
public
static
TView
GetOrCreateManagedViewFromComData<T, TView>
(
object
comObject, Func<T, TView> createCallback)
9
{
10
object
typeFromHandle = typeof(TView);
11
object
comObjectData =
Marshal
.
GetComObjectData
(comObject, typeFromHandle);
12
if
(comObjectData is TView)
13
{
14
return
(TView)comObjectData;
15
}
16
TView val = createCallback((T)comObject);
17
if
(!
Marshal
.
SetComObjectData
(comObject, typeFromHandle, val))
18
{
19
val = (TView)
Marshal
.
GetComObjectData
(comObject, typeFromHandle);
20
}
21
return
val;
22
}
23
}
System.Runtime.InteropServices.CustomMarshalers.ComDataHelpers.GetOrCreateManagedViewFromComData< T, TView >
static TView GetOrCreateManagedViewFromComData< T, TView >(object comObject, Func< T, TView > createCallback)
Definition
ComDataHelpers.cs:8
System.Runtime.InteropServices.CustomMarshalers.ComDataHelpers
Definition
ComDataHelpers.cs:6
System.Runtime.InteropServices.Marshal.SetComObjectData
static bool SetComObjectData(object obj, object key, object? data)
Definition
Marshal.cs:428
System.Runtime.InteropServices.Marshal.GetComObjectData
static ? object GetComObjectData(object obj, object key)
Definition
Marshal.cs:406
System.Runtime.InteropServices.Marshal
Definition
Marshal.cs:14
System.Runtime.InteropServices.CustomMarshalers
Definition
ComDataHelpers.cs:3
System.Runtime.Versioning
Definition
NonVersionableAttribute.cs:1
source
System.Private.CoreLib
System.Runtime.InteropServices.CustomMarshalers
ComDataHelpers.cs
Generated by
1.10.0