Exemplo n.º 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());
            }
        }
Exemplo n.º 2
0
        public void Dispatch <T>(object tag, T action)
        {
            var key = new DictionaryKey(tag, typeof(T));

            if (observerDictionary.ContainsKey(key))
            {
                foreach (var caller in observerDictionary[key].Values)
                {
                    caller(action);
                }
            }
        }
Exemplo n.º 3
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);
            };
        }