43 lines
1008 B
C#
43 lines
1008 B
C#
|
|
using System;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using AlicizaX.Runtime;
|
|||
|
|
|
|||
|
|
namespace AlicizaX.EventKit.Runtime
|
|||
|
|
{
|
|||
|
|
/// <summary>
|
|||
|
|
/// 事件工具类
|
|||
|
|
/// </summary>
|
|||
|
|
public static class EventKit
|
|||
|
|
{
|
|||
|
|
private static EventPublisher _publisher;
|
|||
|
|
public static EventPublisher Publisher => _publisher;
|
|||
|
|
|
|||
|
|
private static List<Action> eventMaps = new List<Action>();
|
|||
|
|
|
|||
|
|
internal static void Init()
|
|||
|
|
{
|
|||
|
|
eventMaps = new List<Action>();
|
|||
|
|
_publisher = new EventPublisher();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
internal static void Release()
|
|||
|
|
{
|
|||
|
|
_publisher = null;
|
|||
|
|
foreach (var _event in eventMaps)
|
|||
|
|
{
|
|||
|
|
_event();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
eventMaps.Clear();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 外部不允许调用
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="action"></param>
|
|||
|
|
public static void AddResetHandler(Action action)
|
|||
|
|
{
|
|||
|
|
eventMaps.Add(action);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|