using System; using System.Collections.Concurrent; namespace SHJX.Service.Common.UserDelegate { public static class Messager { private static readonly ConcurrentDictionary> Actions = new(); /// /// 注册 /// /// /// public static void Register(string deleName, Action action) { if (!Actions.ContainsKey(deleName)) { Actions.TryAdd(deleName, action); } Actions[deleName] = action; } /// /// 发送 /// /// /// public static void Send(string opKey, object arg = null) { if (Actions.TryGetValue(opKey, out var service)) { service?.Invoke(arg); } } } }