/
NWPathMonitor.cs
58 lines (46 loc) · 1.58 KB
/
NWPathMonitor.cs
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
//
// NWPath.cs: Bindings the Netowrk nw_path_monitor_t API.
//
// Authors:
// Miguel de Icaza (miguel@microsoft.com)
//
// Copyrigh 2018 Microsoft Inc
//
using System;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
using ObjCRuntime;
using Foundation;
using CoreFoundation;
namespace Network {
[TV (12,0), Mac (10,14, onlyOn64: true), iOS (12,0)]
public class NWPathMonitor : NativeObject {
public NWPathMonitor (IntPtr handle, bool owns) : base (handle, owns) {}
[DllImport (Constants.NetworkLibrary)]
extern static IntPtr nw_path_monitor_create ();
public NWPathMonitor ()
{
InitializeHandle (nw_path_monitor_create ());
}
[DllImport (Constants.NetworkLibrary)]
extern static IntPtr nw_path_monitor_create_with_type (NWInterfaceType interfaceType);
public NWPathMonitor (NWInterfaceType interfaceType)
{
InitializeHandle (nw_path_monitor_create_with_type (interfaceType));
}
[DllImport (Constants.NetworkLibrary)]
extern static void nw_path_monitor_cancel (IntPtr handle);
public void Cancel () => nw_path_monitor_cancel (GetCheckedHandle ());
[DllImport (Constants.NetworkLibrary)]
extern static void nw_path_monitor_start (IntPtr handle);
public void Start () => nw_path_monitor_start (GetCheckedHandle ());
[DllImport (Constants.NetworkLibrary)]
extern static void nw_path_monitor_set_queue (IntPtr handle, IntPtr queue);
public void SetQueue (DispatchQueue queue)
{
if (queue == null)
throw new ArgumentNullException (nameof (queue));
nw_path_monitor_set_queue (GetCheckedHandle (), queue.Handle);
}
}
}