Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ GetOrCreateManagedViewFromComData< T, TView >()

static TView System.Runtime.InteropServices.CustomMarshalers.ComDataHelpers.GetOrCreateManagedViewFromComData< T, TView > ( object comObject,
Func< T, TView > createCallback )
inlinestatic

Definition at line 8 of file ComDataHelpers.cs.

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 }

References System.Runtime.InteropServices.Marshal.GetComObjectData(), and System.Runtime.InteropServices.Marshal.SetComObjectData().