Ejemplo n.º 1
0
        /// <summary>
        /// 订阅执行事件
        /// </summary>
        /// <param name="handler">事件回调对象句柄</param>
        /// <param name="eventID">事件ID</param>
        /// <param name="sourceID">发送源标识</param>
        /// <returns></returns>
        static public bool Subscibe(IEventHandler handler, U3D_Render.Utility.EVENT eventID, int sourceID)
        {
            SEventKey key = new SEventKey(eventID, sourceID);

            if (!m_collections.ContainsKey(key))
            {
                m_collections[key] = new EventCollect();
            }

            return(m_collections[key].Add(handler));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 取消订阅执行事件
        /// </summary>
        /// <param name="handler">事件回调对象句柄</param>
        /// <param name="eventID">事件ID</param>
        /// <param name="sourceID">发送源标识</param>
        /// <returns></returns>

        static public bool UnSubscibe(IEventHandler handler, U3D_Render.Utility.EVENT eventID, int sourceID)
        {
            SEventKey key = new SEventKey(eventID, sourceID);

            if (!m_collections.ContainsKey(key))
            {
                return(true);
            }

            return(m_collections[key].Remove(handler));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 发送执行事件
        /// </summary>
        /// <param name="eventID">事件ID</param>
        /// <param name="sourceID">发送源标识</param>
        /// <param name="objEvent">事件上下文</param>
        static public void FireExecute(U3D_Render.Utility.EVENT eventID, int sourceID, System.Object objEvent)
        {
            SEventKey key1 = new SEventKey(eventID, sourceID);

            if (sourceID > 0 && m_collections.ContainsKey(key1))
            {
                m_collections[key1].OnEvent(eventID, sourceID, objEvent);
            }

            SEventKey key2 = new SEventKey(eventID, 0);

            if (m_collections.ContainsKey(key2))
            {
                m_collections[key2].OnEvent(eventID, sourceID, objEvent);
            }
        }