public async Task HandleAsync(TEvent @event, ICorrelationContext context) { if (@event.BelongsToSaga()) { var sagaContext = SagaContext.CreateFromCorrelationContext(context); await sagaCoordinator.ProcessAsync(@event, sagaContext); } }
public async Task PublishAsync <TEvent>(TEvent @event, ICorrelationContext context) where TEvent : IEvent { if (@event.BelongsToSaga()) { var sagaContext = SagaContext.CreateFromCorrelationContext(context); await sagaCoordinator.ProcessAsync(@event, sagaContext); } else { await busClient.PublishAsync(@event, ctx => ctx.UseMessageContext(context)); } }