Exemple #1
0
 /// <summary>
 /// 取消订阅一型事件
 /// </summary>
 /// <param name="type">事件处理类</param>
 /// <param name="handler">事件处理者</param>
 public void Unsubscribe(Type type, HTFAction <object, EventHandlerBase> handler)
 {
     if (EventHandlerList1.ContainsKey(type))
     {
         EventHandlerList1[type] -= handler;
     }
 }
Exemple #2
0
 /// <summary>
 /// 订阅一型事件
 /// </summary>
 /// <param name="type">事件处理类</param>
 /// <param name="handler">事件处理者</param>
 public void Subscribe(Type type, HTFAction <object, EventHandlerBase> handler)
 {
     if (EventHandlerList1.ContainsKey(type))
     {
         EventHandlerList1[type] += handler;
     }
     else
     {
         throw new HTFrameworkException(HTFrameworkModule.Event, "订阅I型事件失败:不存在可以订阅的事件类型 " + type.Name + " !");
     }
 }
Exemple #3
0
 /// <summary>
 /// 清空已订阅的事件
 /// </summary>
 /// <param name="type">事件处理类</param>
 public void ClearSubscribe(Type type)
 {
     if (EventHandlerList1.ContainsKey(type))
     {
         EventHandlerList1[type] = null;
     }
     if (EventHandlerList2.ContainsKey(type))
     {
         EventHandlerList2[type] = null;
     }
     if (EventHandlerList3.ContainsKey(type))
     {
         EventHandlerList3[type] = null;
     }
 }
Exemple #4
0
        /// <summary>
        /// 抛出一型事件(抛出事件时,请使用引用池生成事件处理者实例)
        /// </summary>
        /// <param name="sender">事件发送者</param>
        /// <param name="handler">事件处理类实例</param>
        public void Throw(object sender, EventHandlerBase handler)
        {
            Type type = handler.GetType();

            if (EventHandlerList1.ContainsKey(type))
            {
                if (EventHandlerList1[type] != null)
                {
                    EventHandlerList1[type](sender, handler);
                    Main.m_ReferencePool.Despawn(handler);
                }
            }
            else
            {
                throw new HTFrameworkException(HTFrameworkModule.Event, "抛出I型事件失败:不存在可以抛出的事件类型 " + type.Name + " !");
            }
        }