Exemplo n.º 1
0
        async Task IPipe <PublishContext <TMessage> > .Send(PublishContext <TMessage> context)
        {
            {
                if (_observers.Count > 0)
                {
                    await _observers.PrePublish(context).ConfigureAwait(false);
                }
                try
                {
                    await _outputPipe.Send(context).ConfigureAwait(false);

                    if (_observers.Count > 0)
                    {
                        await _observers.PostPublish(context).ConfigureAwait(false);
                    }
                }
                catch (Exception ex)
                {
                    if (_observers.Count > 0)
                    {
                        await _observers.PublishFault(context, ex).ConfigureAwait(false);
                    }

                    throw;
                }
            }
        }
Exemplo n.º 2
0
        async Task IFilter <PublishContext> .Send(PublishContext context, IPipe <PublishContext> next)
        {
            var publishContext = context as PublishContext <TMessage>;

            if (publishContext != null)
            {
                if (_messageObservers.Count > 0)
                {
                    await _messageObservers.PrePublish(publishContext).ConfigureAwait(false);
                }
                try
                {
                    await _outputPipe.Send(publishContext).ConfigureAwait(false);

                    if (_messageObservers.Count > 0)
                    {
                        await _messageObservers.PostPublish(publishContext).ConfigureAwait(false);
                    }

                    await next.Send(context).ConfigureAwait(false);
                }
                catch (Exception ex)
                {
                    if (_messageObservers.Count > 0)
                    {
                        await _messageObservers.PublishFault(publishContext, ex).ConfigureAwait(false);
                    }

                    throw;
                }
            }
        }