Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
ComDataHelpers.cs
Go to the documentation of this file.
2
4
5internal 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}
static TView GetOrCreateManagedViewFromComData< T, TView >(object comObject, Func< T, TView > createCallback)
static bool SetComObjectData(object obj, object key, object? data)
Definition Marshal.cs:428
static ? object GetComObjectData(object obj, object key)
Definition Marshal.cs:406