Exemplo n.º 1
0
 /// <summary>
 /// 取消订阅二型事件
 /// </summary>
 /// <param name="type">事件处理类</param>
 /// <param name="handler">事件处理者</param>
 public void Unsubscribe(Type type, HTFAction handler)
 {
     if (EventHandlerList2.ContainsKey(type))
     {
         EventHandlerList2[type] -= handler;
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// 抛出二型事件
 /// </summary>
 /// <param name="type">事件处理类</param>
 public void Throw(Type type)
 {
     if (EventHandlerList2.ContainsKey(type))
     {
         EventHandlerList2[type]?.Invoke();
     }
     else
     {
         throw new HTFrameworkException(HTFrameworkModule.Event, "抛出II型事件失败:不存在可以抛出的事件类型 " + type.Name + " !");
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// 订阅二型事件
 /// </summary>
 /// <param name="type">事件处理类</param>
 /// <param name="handler">事件处理者</param>
 public void Subscribe(Type type, HTFAction handler)
 {
     if (EventHandlerList2.ContainsKey(type))
     {
         EventHandlerList2[type] += handler;
     }
     else
     {
         throw new HTFrameworkException(HTFrameworkModule.Event, "订阅II型事件失败:不存在可以订阅的事件类型 " + type.Name + " !");
     }
 }
Exemplo n.º 4
0
        /// <summary>
        /// 初始化助手
        /// </summary>
        public void OnInitialization()
        {
            List <Type> types = ReflectionToolkit.GetTypesInRunTimeAssemblies(type =>
            {
                return(type.IsSubclassOf(typeof(EventHandlerBase)) && !type.IsAbstract);
            });

            for (int i = 0; i < types.Count; i++)
            {
                EventHandlerList1.Add(types[i], null);
                EventHandlerList2.Add(types[i], null);
                EventHandlerList3.Add(types[i], null);
            }
        }
Exemplo n.º 5
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;
     }
 }
Exemplo n.º 6
0
 /// <summary>
 /// 终结助手
 /// </summary>
 public void OnTermination()
 {
     EventHandlerList1.Clear();
     EventHandlerList2.Clear();
     EventHandlerList3.Clear();
 }