/// <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)); }
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>()); }
public Builder WithTopicHandler <TTopic>(TopicHandlerDelegate <TTopic> handler) { TopicDispatcher.Register(handler); return(this); }
public IHandlerSetup WithTopicHandler <TTopic>(TopicHandlerDelegate <TTopic> handler) where TTopic : class { topicDispatcher.Register(handler); return(this); }