public static IServiceCollection AddEventManagerCore <TPublisher, TCacheManager>(this IServiceCollection collection, Action <EventManagerOptions> eventManagerOptionsAction = null ) where TPublisher : IMessagePublisher where TCacheManager : ICacheManager { eventManagerOptionsAction = eventManagerOptionsAction ?? (x => { }); collection.Configure(eventManagerOptionsAction); collection.AddTransient <IEventChecker, EventChecker <TCacheManager> >(); collection.AddTransient <IEMPublisher, EventPublisherCore <TPublisher> >(); EventManagerOptions opt = new EventManagerOptions(); eventManagerOptionsAction.Invoke(opt); if (opt.CheckIsEventUnique) { collection.AddTransient <IEventManagerCore, EventManagerWithChecker>(); } else { collection.AddTransient <IEventManagerCore, EventManagerCore>(); } return(collection); }
public EventManagerCore(IOptions <EventManagerOptions> options) { if (options.Value == null) { throw new Exception("EventManagerOptions can not be null"); } _options = options.Value; }
public EventChecker(IEventInfoLoader eventInfoLoader, TCacheManager cacheManager, IOptions <EventManagerOptions> options) { _eventInfoLoader = eventInfoLoader; _cacheManager = cacheManager; if (options.Value == null) { throw new Exception("EventManagerOptions can not be null"); } _options = options.Value; }