示例#1
0
        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());
            }
        }
示例#2
0
        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); };
        }