public static void RegisterAndRun <Tsrv, Tin>(ILifetimeScope lifetimeScope, string topic, string methodName) { Channel <Tin> channel = Channel.CreateUnbounded <Tin>(); var eventdelegate = CreateMethodDelegate <Tsrv, Tin>(typeof(Tsrv).GetMethod(methodName)); _ = SubscribeHandleInvoke((lifetimeScope as LifetimeScope).RootLifetimeScope, channel, eventdelegate); ChannelDictionary.SetChannel(topic, channel); }
public async Task SendEvent <T>(string topic, List <T> datas) { var channel = ChannelDictionary.GetChannel <T>(topic); if (channel != null) { foreach (var item in datas) { await channel.Writer.WriteAsync(item); } } else { throw new Exception("未注册事件订阅器!"); } }