/// <summary> /// 注册事件 /// </summary> /// <param name="eventName"></param> /// <param name="handle"></param> public static void Register(string eventName, EventHandle handle) { if (!Handles.ContainsKey(eventName)) { Handles.Add(eventName, new List <EventHandle>()); } Handles[eventName].Add(handle); }
/// <summary> /// 注册事件 /// </summary> /// <param name="eventName"></param> /// <param name="handle"></param> /// <param name="key"></param> public static void Register(string eventName, EventHandle handle, string key) { if (ClientKeys.ContainsKey(key)) { return; } lock (RegisterLocker) { if (ClientKeys.ContainsKey(key)) { return; } ClientKeys.Add(key, new object()); } if (!Handles.ContainsKey(eventName)) { Handles.Add(eventName, new List <EventHandle>()); } Handles[eventName].Add(handle); }