-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathTest_ManagedEntryPoint.cs
More file actions
40 lines (35 loc) · 1.07 KB
/
Test_ManagedEntryPoint.cs
File metadata and controls
40 lines (35 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
using System;
using System.Reflection.Metadata.Ecma335;
using System.Runtime.InteropServices;
namespace LibNamespace
{
public static class Test_ManagedEntryPoint
{
// begin-snippet: Test_ManagedEntryPoint_Args_CS
[StructLayout(LayoutKind.Sequential)]
public unsafe struct Args
{
public int Number1;
public int Number2;
}
// end-snippet
// begin-snippet: Test_ManagedEntryPoint_ComponentEntryPoint_CS
public static int Test_ComponentEntryPoint(IntPtr arg, int argLength)
{
if (argLength < Marshal.SizeOf(typeof(Args)))
{
return 1;
}
Args args = Marshal.PtrToStructure<Args>(arg);
return args.Number1 + args.Number2;
}
// end-snippet
// begin-snippet: Test_ManagedEntryPoint_CustomEntryPoint_CS
[UnmanagedCallersOnly]
public static int Test_CustomEntryPoint(Args args)
{
return args.Number1 + args.Number2;
}
// end-snippet
}
}