Esempio n. 1
0
        /// <summary>
        /// 手动绑定事件源与事件处理
        /// </summary>
        /// <param name="eventType"></param>
        /// <param name="handlerType"></param>
        public void Register(Type eventType, Type handlerType)
        {
            //注册IEventHandler<T>到IOC容器
            var handlerInterface = handlerType.GetInterface("IEventHandler`1");

            if (!IocContainer.Kernel.HasComponent(handlerInterface))
            {
                IocContainer.Register(
                    Component.For(handlerInterface, handlerType));
            }

            _eventStore.AddRegister(eventType, handlerType);
        }
Esempio n. 2
0
        public void Register(Type eventType, Type handler)
        {
            //注册IEventHandler<T>到IOC容器
            var handlerInterface = handler.GetInterface("IEventHandler`1");

            if (!IocContainer.Kernel.HasComponent(handlerInterface))
            {
                IocContainer.Register(
                    Component.For(handlerInterface, handler));
            }
            if (!_eventStore.HasRegisterForEvent(eventType))
            {
                using (var connection = _connectionFactory.CreateConnection())
                {
                    using (var channel = connection.CreateModel())
                    {
                        channel.QueueBind(queue: _queueName, exchange: BrokerName, routingKey: eventType.Name);
                    }
                }
            }
            _eventStore.AddRegister(eventType, handler);
        }
Esempio n. 3
0
 /// <summary>
 /// 手动绑定事件源与事件处理
 /// </summary>
 /// <param name="eventType"></param>
 /// <param name="handlerType"></param>
 public void Register(Type eventType, Type handlerType)
 {
     //注册IEventHandler<T>到IOC容器
     _eventStore.AddRegister(eventType, handlerType);
 }