Esempio n. 1
0
        public static void Unregister <T>(string key, object owner)
        {
            MessageCenterKey mcKey = new MessageCenterKey(key, typeof(T));

            if (registeredListeners.ContainsKey(mcKey))
            {
                registeredListeners[mcKey].Remove(owner);
            }
        }
Esempio n. 2
0
        public static void Register <T>(string key, object owner, Action <T> listener)
        {
            MessageCenterKey mcKey = new MessageCenterKey(key, typeof(T));

            if (!registeredListeners.ContainsKey(mcKey))
            {
                registeredListeners[mcKey] = new Dictionary <object, Action <object> >();
            }
            registeredListeners[mcKey][owner] = (value) => { listener((T)value); };
        }
Esempio n. 3
0
        public static void Send <T>(string key, T data)
        {
            MessageCenterKey mcKey = new MessageCenterKey(key, typeof(T));

            if (registeredListeners.ContainsKey(mcKey))
            {
                foreach (var listener in registeredListeners[mcKey].Values)
                {
                    listener(data);
                }
            }
        }