Пример #1
0
        /// <summary>
        /// Registers a <see cref="TopicHandlerDelegate{TEvent}"/>
        /// </summary>
        /// <typeparam name="TTopic">Type of the topic message</typeparam>
        /// <param name="handler">Topic message handler</param>
        public void Register <TTopic>(TopicHandlerDelegate <TTopic> handler)
        {
            Validate <TTopic>();

            // Note: don't need to GetAwaiter().GetResult() since there is no return
            handlers.Add(
                typeof(TTopic),
                eventMessage => handler((TTopic)eventMessage));
        }
Пример #2
0
        public void Register_WithTopicHandlerDelegate_WithUnserializableTopic_ThrowsUnserializableTypeException()
        {
            // Arrange
            var dispatcher = new TopicDispatcher();
            TopicHandlerDelegate <UnserializableTopic> handler = _ => { };

            // Act
            TestDelegate register = () => dispatcher.Register(handler);

            // Assert
            Assert.That(register, Throws.TypeOf <UnserializableTypeException>());
        }
Пример #3
0
 public Builder WithTopicHandler <TTopic>(TopicHandlerDelegate <TTopic> handler)
 {
     TopicDispatcher.Register(handler);
     return(this);
 }
Пример #4
0
 public IHandlerSetup WithTopicHandler <TTopic>(TopicHandlerDelegate <TTopic> handler) where TTopic : class
 {
     topicDispatcher.Register(handler);
     return(this);
 }