private static void SubscribeInteral <T>(string id, Action <T> callback) { string typeKey = typeof(T).ToString(); if (!messageBrokerMap.ContainsKey(typeKey)) { messageBrokerMap.Add(typeKey, new Dictionary <string, Dictionary <int, SubscriberInfo> >()); } if (!messageBrokerMap[typeKey].ContainsKey(id)) { messageBrokerMap[typeKey].Add(id, new Dictionary <int, SubscriberInfo>()); } int callbackHashCode = callback.GetHashCode(); if (!messageBrokerMap[typeKey][id].ContainsKey(callbackHashCode)) { var subData = new SubscriberInfo() { target = callback.Target, methodCallback = callback.Method }; messageBrokerMap[typeKey][id].Add(callbackHashCode, subData); } }
public static void Subscribe(string id, Action callback) { string typeKey = NoParamsKey; if (!messageBrokerMap.ContainsKey(typeKey)) { messageBrokerMap.Add(typeKey, new Dictionary <string, Dictionary <int, SubscriberInfo> >()); } if (!messageBrokerMap[typeKey].ContainsKey(id)) { messageBrokerMap[typeKey].Add(id, new Dictionary <int, SubscriberInfo>()); } int callbackHashCode = callback.GetHashCode(); if (!messageBrokerMap[typeKey][id].ContainsKey(callbackHashCode)) { var subData = new SubscriberInfo() { target = callback.Target, methodCallback = callback.Method }; messageBrokerMap[typeKey][id].Add(callbackHashCode, subData); } }