示例#1
0
 public virtual Task OnMessagePublishingAsync(MessagePublishingEventArgs e,
                                              CancellationToken cancellationToken = default(CancellationToken))
 {
     return(Task.Run(async() =>
     {
         await MessagePublishing?.Invoke(this, e);
     }, cancellationToken));
 }
示例#2
0
 public virtual async Task PublishAsync <T>(
     T message,
     [CallerMemberName] string callerMemberName = "")
     where T : class, IMessage, new()
 {
     if (message == default(T))
     {
         throw new ArgumentNullException(nameof(message));
     }
     var topic     = message.GetMessageTopicOrDefault <T>();
     var json      = JsonConvert.SerializeObject(message);
     var wrapper   = new MessageWrapper(topic, json);
     var eventArgs = new MessagePublishingEventArgs(wrapper
                                                    , callerMemberName);
     await Task.WhenAll(_publisherWrapper.SendAsync(wrapper),
                        _configuration.OnMessagePublishingAsync(eventArgs));
 }
示例#3
0
 public override Task OnMessagePublishingAsync(MessagePublishingEventArgs e, CancellationToken cancellationToken = default(CancellationToken))
 {
     LatestMessagePublishingEventArgs = e;
     return(base.OnMessagePublishingAsync(e, cancellationToken));
 }