Files
2026-02-26 11:21:27 +03:00

31 lines
884 B
C#

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