-
Notifications
You must be signed in to change notification settings - Fork 0
/
InterfaceEventsSink.cs
136 lines (120 loc) · 6.24 KB
/
InterfaceEventsSink.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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
using System;
using MbnApi;
namespace MBN_DotNet
{
public delegate void OnEmergencyModeChangeHandler(IMbnInterface newInterface);
public delegate void OnHomeProviderAvailableHandler(IMbnInterface newInterface);
public delegate void OnInterfaceCapabilityAvailableHandler(IMbnInterface newInterface);
public delegate void OnPreferredProvidersChangeHandler(IMbnInterface newInterface);
public delegate void OnReadyStateChangeHandler(IMbnInterface newInterface);
public delegate void OnScanNetworkCompleteHandler(IMbnInterface newInterface, uint requestID, int status);
public delegate void OnSetPreferredProvidersCompleteHandler(IMbnInterface newInterface, uint requestID, int status);
public delegate void OnSubscriberInformationChangeHandler(IMbnInterface newInterface);
class InterfaceEventsSink : IMbnInterfaceEvents, IDisposable
{
private WeakReference<OnEmergencyModeChangeHandler> m_OnEmergencyModeChangeCallback;
private WeakReference<OnHomeProviderAvailableHandler> m_OnHomeProviderAvailableCallback;
private WeakReference<OnInterfaceCapabilityAvailableHandler> m_OnInterfaceCapabilityAvailableCallback;
private WeakReference<OnPreferredProvidersChangeHandler> m_OnPreferredProvidersChangeCallback;
private WeakReference<OnReadyStateChangeHandler> m_OnReadyStateChangeCallback;
private WeakReference<OnScanNetworkCompleteHandler> m_OnScanNetworkCompleteCallback;
private WeakReference<OnSetPreferredProvidersCompleteHandler> m_OnSetPreferredProvidersCompleteCallback;
private WeakReference<OnSubscriberInformationChangeHandler> m_OnSubscriberInformationChangeCallback;
private IConnectionPoint m_ConnectionPoint;
private uint m_AdviseCookie;
public InterfaceEventsSink(
OnEmergencyModeChangeHandler onEmergencyModeChangeCallback,
OnHomeProviderAvailableHandler onHomeProviderAvailableCallback,
OnInterfaceCapabilityAvailableHandler onInterfaceCapabilityAvailableCallback,
OnPreferredProvidersChangeHandler onPreferredProvidersChangeCallback,
OnReadyStateChangeHandler onReadyStateChangeCallback,
OnScanNetworkCompleteHandler onScanNetworkCompleteCallback,
OnSetPreferredProvidersCompleteHandler onSetPreferredProvidersCompleteCallback,
OnSubscriberInformationChangeHandler onSubscriberInformationChangeCallback,
IConnectionPoint connectionPoint)
{
m_OnEmergencyModeChangeCallback = new WeakReference<OnEmergencyModeChangeHandler>(onEmergencyModeChangeCallback);
m_OnHomeProviderAvailableCallback = new WeakReference<OnHomeProviderAvailableHandler>(onHomeProviderAvailableCallback);
m_OnInterfaceCapabilityAvailableCallback = new WeakReference<OnInterfaceCapabilityAvailableHandler>(onInterfaceCapabilityAvailableCallback);
m_OnPreferredProvidersChangeCallback = new WeakReference<OnPreferredProvidersChangeHandler>(onPreferredProvidersChangeCallback);
m_OnReadyStateChangeCallback = new WeakReference<OnReadyStateChangeHandler>(onReadyStateChangeCallback);
m_OnScanNetworkCompleteCallback = new WeakReference<OnScanNetworkCompleteHandler>(onScanNetworkCompleteCallback);
m_OnSetPreferredProvidersCompleteCallback = new WeakReference<OnSetPreferredProvidersCompleteHandler>(onSetPreferredProvidersCompleteCallback);
m_OnSubscriberInformationChangeCallback = new WeakReference<OnSubscriberInformationChangeHandler>(onSubscriberInformationChangeCallback);
m_ConnectionPoint = connectionPoint;
m_ConnectionPoint.Advise(this, out m_AdviseCookie);
}
~InterfaceEventsSink()
{
Dispose();
}
public void Dispose()
{
if (m_AdviseCookie != 0)
{
m_ConnectionPoint.Unadvise(m_AdviseCookie);
m_AdviseCookie = 0;
}
}
public void OnInterfaceCapabilityAvailable(IMbnInterface newInterface)
{
throw new NotImplementedException();
}
public void OnSubscriberInformationChange(IMbnInterface newInterface)
{
OnSubscriberInformationChangeHandler callback;
if (m_OnSubscriberInformationChangeCallback.TryGetTarget(out callback))
{
callback.Invoke(newInterface);
}
}
public void OnReadyStateChange(IMbnInterface newInterface)
{
OnReadyStateChangeHandler callback;
if (m_OnReadyStateChangeCallback.TryGetTarget(out callback))
{
callback.Invoke(newInterface);
}
}
public void OnEmergencyModeChange(IMbnInterface newInterface)
{
OnEmergencyModeChangeHandler callback;
if (m_OnEmergencyModeChangeCallback.TryGetTarget(out callback))
{
callback.Invoke(newInterface);
}
}
public void OnHomeProviderAvailable(IMbnInterface newInterface)
{
OnHomeProviderAvailableHandler callback;
if (m_OnHomeProviderAvailableCallback.TryGetTarget(out callback))
{
callback.Invoke(newInterface);
}
}
public void OnPreferredProvidersChange(IMbnInterface newInterface)
{
OnPreferredProvidersChangeHandler callback;
if (m_OnPreferredProvidersChangeCallback.TryGetTarget(out callback))
{
callback.Invoke(newInterface);
}
}
public void OnSetPreferredProvidersComplete(IMbnInterface newInterface, uint requestID, int status)
{
OnSetPreferredProvidersCompleteHandler callback;
if (m_OnSetPreferredProvidersCompleteCallback.TryGetTarget(out callback))
{
callback.Invoke(newInterface, requestID, status);
}
}
public void OnScanNetworkComplete(IMbnInterface newInterface, uint requestID, int status)
{
OnScanNetworkCompleteHandler callback;
if (m_OnScanNetworkCompleteCallback.TryGetTarget(out callback))
{
callback.Invoke(newInterface, requestID, status);
}
}
}
}