コード例 #1
0
        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);
        }
コード例 #2
0
        public EventManagerCore(IOptions <EventManagerOptions> options)
        {
            if (options.Value == null)
            {
                throw new Exception("EventManagerOptions can not be null");
            }

            _options = options.Value;
        }
コード例 #3
0
        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;
        }