async Task IFilter <TInput> .Send(TInput context, IPipe <TInput> next) { TOutput pipeContext; if (_contextConverter.TryConvert(context, out pipeContext)) { if (_observers.Count > 0) { await _observers.PreSend(pipeContext).ConfigureAwait(false); } try { await _outputPipe.Send(pipeContext).ConfigureAwait(false); if (_observers.Count > 0) { await _observers.PostSend(pipeContext).ConfigureAwait(false); } await next.Send(context).ConfigureAwait(false); } catch (Exception ex) { if (_observers.Count > 0) { await _observers.SendFault(pipeContext, ex).ConfigureAwait(false); } throw; } } }
async Task IFilter <TInput> .Send(TInput context, IPipe <TInput> next) { TOutput pipeContext; if (_contextConverter.TryConvert(context, out pipeContext)) { if (_observers.Count > 0) { await _observers.PreSend(pipeContext).ConfigureAwait(false); } try { await _outputPipe.Send(pipeContext).ConfigureAwait(false); if (_observers.Count > 0) { await _observers.PostSend(pipeContext).ConfigureAwait(false); } await next.Send(context).ConfigureAwait(false); } catch (Exception ex) { // we can't await in a catch block, so we have to wait explicitly on this one if (_observers.Count > 0) { await _observers.SendFault(pipeContext, ex).ConfigureAwait(false); } throw; } } }
async Task SendToOutput(TInput context, IPipe <TInput> next, TOutput pipeContext) { if (_observers.Count > 0) { await _observers.PreSend(pipeContext).ConfigureAwait(false); } try { await _outputPipe.Send(pipeContext).ConfigureAwait(false); if (_observers.Count > 0) { await _observers.PostSend(pipeContext).ConfigureAwait(false); } await next.Send(context).ConfigureAwait(false); } catch (Exception ex) { if (_observers.Count > 0) { await _observers.SendFault(pipeContext, ex).ConfigureAwait(false); } throw; } }