using System; using System.Collections.Generic; using System.Linq; namespace Code.Infrastructure.EventBus { internal static class EventBusHelper { private static Dictionary> s_CashedSubscriberTypes = new(); public static List GetSubscriberTypes( IGlobalSubscriber globalSubscriber) { Type type = globalSubscriber.GetType(); if (s_CashedSubscriberTypes.ContainsKey(type)) { return s_CashedSubscriberTypes[type]; } List subscriberTypes = type .GetInterfaces() .Where(t => t.GetInterfaces() .Contains(typeof(IGlobalSubscriber))) .ToList(); s_CashedSubscriberTypes[type] = subscriberTypes; return subscriberTypes; } } }