-
Notifications
You must be signed in to change notification settings - Fork 1
/
Alert.cs
105 lines (89 loc) · 2.72 KB
/
Alert.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.InteropServices;
namespace Tsunami.Core
{
using AlertHandle = HandleRef;
public class Alert : IDisposable
{
#region PInvoke
[DllImport("TsunamiBridge", CallingConvention = CallingConvention.StdCall)]
public static extern void Alert_Destroy(AlertHandle handle);
[DllImport("TsunamiBridge", CallingConvention = CallingConvention.StdCall)]
public static extern void Alert_What_Get(AlertHandle handle, StringBuilder str, int size);
[DllImport("TsunamiBridge", CallingConvention = CallingConvention.StdCall)]
public static extern void Alert_Message_Get(AlertHandle handle, StringBuilder str, int size);
[DllImport("TsunamiBridge", CallingConvention = CallingConvention.StdCall)]
public static extern int Alert_Type_Get(AlertHandle handle);
[DllImport("TsunamiBridge", CallingConvention = CallingConvention.StdCall)]
public static extern int Alert_Category_Get(AlertHandle handle);
#endregion PInvoke
protected AlertHandle handle;
private StringBuilder sb = new StringBuilder(256);
public Alert(IntPtr h)
{
handle = new HandleRef(this, h);
}
private string what;
public string What
{
get
{
if (String.IsNullOrEmpty(what))
{
Alert_What_Get(handle, sb, sb.Capacity);
what = sb.ToString();
}
return what;
}
}
private string message;
public string Message
{
get
{
if (String.IsNullOrEmpty(message))
{
Alert_Message_Get(handle, sb, sb.Capacity);
message = sb.ToString();
}
return message;
}
}
private int type;
public int Type
{
get
{
type = Alert_Type_Get(handle);
return type;
}
}
private AlertMask category;
public AlertMask Category
{
get
{
category = (AlertMask)Alert_Category_Get(handle);
return category;
}
}
public void Dispose()
{
CleanUp();
GC.SuppressFinalize(this);
}
private void CleanUp()
{
Alert_Destroy(handle);
handle = new HandleRef(this, IntPtr.Zero);
}
~Alert()
{
CleanUp();
}
}
}