Beispiel #1
0
        /// <summary>
        /// 订阅事件列表
        /// </summary>
        /// <typeparam name="TEvent"></typeparam>
        /// <param name="eventHandler"></param>
        public void Subscribe <TEvent>(IBusHandler <TEvent> eventHandler)
            where TEvent : class, IBusData
        {
            var eventKey = typeof(TEvent).Name;
            var key      = typeof(TEvent).Name + "_" + eventHandler.GetType().Name;
            Dictionary <string, List <string> > keyDic = new Dictionary <string, List <string> >();

            if (keyDic.ContainsKey(eventKey))
            {
                var oldEvent = keyDic[eventKey];
                oldEvent.Add(key);
            }
            else
            {
                var newEvent = new List <string>();
                newEvent.Add(key);
                keyDic.Add(eventKey, newEvent);
            }

            container.Register(typeof(IBusHandler <TEvent>), eventHandler.GetType(), key);
            //redis存储事件与处理程序的映射关系
            foreach (var hash in keyDic)
            {
                RedisManager.Instance.GetDatabase().HashSet(
                    ESBKEY,
                    hash.Key.ToString(),
                    JsonConvert.SerializeObject(hash.Value));
            }
        }
Beispiel #2
0
 /// <summary>
 /// 订阅事件列表
 /// </summary>
 /// <param name="type"></param>
 /// <param name="subTypeList"></param>
 public void Subscribe <TEvent>(IBusHandler <TEvent> eventHandler)
     where TEvent : class, IBusData
 {
     lock (_objLock)
     {
         var eventType = typeof(TEvent);
         if (_eventHandlers.ContainsKey(eventType))
         {
             var handlers = _eventHandlers[eventType];
             if (handlers != null)
             {
                 if (!handlers.Exists(deh => _eventHandlerEquals(deh, eventHandler)))
                 {
                     handlers.Add(eventHandler);
                 }
             }
             else
             {
                 handlers = new List <object>();
                 handlers.Add(eventHandler);
             }
         }
         else
         {
             _eventHandlers.Add(eventType, new List <object> {
                 eventHandler
             });
         }
     }
 }
Beispiel #3
0
 public BuyCattleHandler(IBusHandler bus,
                         IHandleMessages <DomainNotification> notifications,
                         IUoW uow,
                         IBuyCattleRepository buyCattleRepository) :
     base(bus, notifications, uow)
 {
     _buyCattleRepository = buyCattleRepository;
 }
Beispiel #4
0
 protected CommandHandler(IBusHandler bus,
                          IHandleMessages <DomainNotification> notifications,
                          IUoW uow)
 {
     _notifications = (DomainNotificationHandler)notifications;
     _bus           = bus;
     _uow           = uow;
 }
Beispiel #5
0
 public BankAccountHandler(IBusHandler bus,
                           IHandleMessages <DomainNotification> notifications,
                           IUoW uow,
                           IBankAccountRepository bankAccountRepository) :
     base(bus, notifications, uow)
 {
     _bankAccountRepository = bankAccountRepository;
 }
Beispiel #6
0
 /// <summary>
 /// 取消订阅事件
 /// </summary>
 /// <param name="type"></param>
 /// <param name="subType"></param>
 public void Unsubscribe <TEvent>(IBusHandler <TEvent> eventHandler)
     where TEvent : class, IBusData
 {
     lock (_objLock)
     {
         _redisClient.SetRemove(GetCurrentRedisKey <TEvent>(), JsonConvert.SerializeObject((eventHandler)));
     }
 }
Beispiel #7
0
 /// <summary>
 /// 订阅事件列表
 /// </summary>
 /// <typeparam name="TEvent"></typeparam>
 /// <param name="eventHandler"></param>
 public void Subscribe <TEvent>(IBusHandler <TEvent> eventHandler)
     where TEvent : class, IBusData
 {
     lock (_objLock)
     {
         var newVal = JsonConvert.SerializeObject(eventHandler);
         _redisClient.SetAdd(GetCurrentRedisKey <TEvent>(), newVal);
     }
 }
Beispiel #8
0
 public DailyExtractLotHandler(IBusHandler bus,
                               IHandleMessages <DomainNotification> notifications,
                               IUoW uow,
                               IDailyExtractLotCreateDomainService dailyExtractLotCreateDomainService,
                               IDailyExtractLotRepository dailyExtractLotRepository) :
     base(bus, notifications, uow)
 {
     _dailyExtractLotCreateDomainService = dailyExtractLotCreateDomainService;
     _dailyExtractLotRepository          = dailyExtractLotRepository;
 }
Beispiel #9
0
 /// <summary>
 /// 取消订阅事件
 /// </summary>
 /// <param name="type"></param>
 /// <param name="subType"></param>
 public void Unsubscribe <TEvent>(IBusHandler <TEvent> eventHandler)
     where TEvent : class, IBusData
 {
     lock (_objLock)
     {
         var eventType = typeof(TEvent);
         if (_eventHandlers.ContainsKey(eventType))
         {
             var handlers = _eventHandlers[eventType];
             if (handlers != null &&
                 handlers.Exists(deh => _eventHandlerEquals(deh, eventHandler)))
             {
                 var handlerToRemove = handlers.First(deh => _eventHandlerEquals(deh, eventHandler));
                 handlers.Remove(handlerToRemove);
             }
         }
     }
 }
Beispiel #10
0
 public DiceCommandHandler(IDiceRepository repository, IUnitOfWork uow, IBusHandler bus) : base(uow, bus)
 {
     _repository = repository;
     Bus         = bus;
 }
Beispiel #11
0
 public SagaBuyWorkflow(IBusHandler bus)
 {
     _bus = bus;
 }
Beispiel #12
0
 public IntegrationEventHandler(IBusHandler bus)
 {
     _bus = bus;
 }
Beispiel #13
0
 public BankAccountService(IBusHandler bus,
                           IBankAccountRepository bankAccountRepository)
 {
     _bus = bus;
     _bankAccountRepository = bankAccountRepository;
 }
Beispiel #14
0
 public BuyCattleService(IBusHandler bus)
 {
     _bus = bus;
 }
 public WheelOfFortuneCommandHandler(IWheelOfFortuneRepository repository, IUnitOfWork uow, IBusHandler bus) : base(uow, bus)
 {
     _repository = repository;
     Bus         = bus;
 }
Beispiel #16
0
 public CommandHandler(IUnitOfWork uow, IBusHandler bus)
 {
     _uow = uow;
     _bus = bus;
 }
Beispiel #17
0
 public CreateDailyExtractLotIntegrationEventHandler(IBusHandler bus) :
     base(bus)
 {
 }
Beispiel #18
0
 /// <summary>
 /// 取消订阅事件
 /// </summary>
 /// <param name="type"></param>
 /// <param name="subType"></param>
 public void Unsubscribe <TEvent>(IBusHandler <TEvent> eventHandler)
     where TEvent : class, IBusData
 {
     _iEventBus.Unsubscribe <TEvent>(eventHandler);
 }
Beispiel #19
0
 /// <summary>
 /// 取消订阅事件
 /// </summary>
 /// <param name="type"></param>
 /// <param name="subType"></param>
 public void Unsubscribe <TEvent>(IBusHandler <TEvent> eventHandler)
     where TEvent : class, IBusData
 {
     throw new NotImplementedException("本方法不被实现");
 }
Beispiel #20
0
 public DiceApplicationService(IDiceRepository repository, IBusHandler bus, IMapper mapper)
 {
     _repository = repository;
     _mapper     = mapper;
     Bus         = bus;
 }
 public WheelOfFortuneApplicationService(IWheelOfFortuneRepository repository, IBusHandler bus, IMapper mapper)
 {
     _repository = repository;
     _mapper     = mapper;
     Bus         = bus;
 }
Beispiel #22
0
 public DailyExtractLotService(IBusHandler bus)
 {
     _bus = bus;
 }