public void Unsubscribe <T>(object tag, OnEvent <T> eventCallback) { var key = new DictionaryKey(tag, typeof(T)); if (observerDictionary[key] != null) { observerDictionary[key].Remove(eventCallback.GetHashCode()); } }
public void Subscribe <T>(object tag, OnEvent <T> eventCallback) { var key = new DictionaryKey(tag, typeof(T)); if (!observerDictionary.ContainsKey(key)) { observerDictionary[key] = new Dictionary <int, OnEventWrapper>(); } observerDictionary[key][eventCallback.GetHashCode()] = (object _object) => { eventCallback((T)_object); }; }