예제 #1
0
        public static void FireTypedEvent <TEventParam>(TypedDelegate <TEventParam> pEvent, TEventParam pParam)
        {
            TypedDelegate <TEventParam> eh = pEvent;

            if (eh != null)
            {
                eh(pParam);
            }
        }
예제 #2
0
        /// <summary>
        /// Removes a listener for a specified event type.
        /// </summary>
        public virtual void RemoveListener <T>(TypedDelegate <T> listener) where T : class
        {
            var type = typeof(T);

            if (delegates.ContainsKey(type))
            {
                delegates[type].Remove(listener);
                return;
            }
        }
예제 #3
0
        /// <summary>
        /// Adds a listener for a specified event type.
        /// </summary>
        public virtual void AddListener <T>(TypedDelegate <T> listener) where T : class
        {
            var type = typeof(T);

            if (!delegates.ContainsKey(type))
            {
                delegates.Add(type, new List <Delegate>());
            }

            var list = delegates[type];

            if (!list.Contains(listener))
            {
                list.Add(listener);
            }
        }