-
Notifications
You must be signed in to change notification settings - Fork 0
/
CallbackChannelManager.cs
executable file
·72 lines (63 loc) · 1.99 KB
/
CallbackChannelManager.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
using System;
using System.Collections.Generic;
using System.Linq;
namespace SIM.Connect
{
public class CallbackChannelManager
{
Dictionary<string, object> mCallbackChannels;
private static volatile CallbackChannelManager sInstance;
private static object sLocker = new object();
static public CallbackChannelManager Instance
{
get
{
if (sInstance == null)
{
lock (sLocker)
{
if (sInstance == null)
{
sInstance = new CallbackChannelManager();
}
}
}
return sInstance;
}
}
private CallbackChannelManager()
{
this.mCallbackChannels = new Dictionary<string, object>();
}
public object GetCallbackChannel(string iCallbackChannelType)
{
foreach (var wCallbackCh in this.mCallbackChannels)
{
if (wCallbackCh.Key == iCallbackChannelType)
{
return wCallbackCh.Value;
}
}
return null;
}
public void AddCallbackChannel(string iCallbackChannelType, object iCallbackChannel)
{
if (this.mCallbackChannels.Keys.Contains(iCallbackChannelType))
{
this.mCallbackChannels.Remove(iCallbackChannelType);
}
try
{
this.mCallbackChannels.Add(iCallbackChannelType, iCallbackChannel);
}
catch(Exception ex)
{
Console.WriteLine(ex.StackTrace);
}
}
public void RemoveCallbackChannel(string iCallbackChannelType)
{
this.mCallbackChannels.Remove(iCallbackChannelType);
}
}
}