public void Publish <T>(T message, Action <IPublishContext <T> > contextCallback) where T : class { PublishedMessage <T> published = null; try { _bus.Publish(message, context => { published = new PublishedMessage <T>(context); contextCallback(context); }); } catch (Exception ex) { if (published != null) { published.SetException(ex); } throw; } finally { if (published != null) { _published.Add(published); _scenario.AddPublished(published); } } }
Task IPublishObserver.PostPublish <T>(PublishContext <T> context) { _messages.Add(context); return(TaskUtil.Completed); }
public void AddPublished(IPublishedMessage message) { _published.Add(message); }