Skip to content

Instantly share code, notes, and snippets.

@dcomartin
Created November 18, 2016 01:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dcomartin/f9976784734d7251e2cce5e0823df61e to your computer and use it in GitHub Desktop.
Save dcomartin/f9976784734d7251e2cce5e0823df61e to your computer and use it in GitHub Desktop.
public class Pipeline<TRequest, TResponse>
: ICancellableAsyncRequestHandler<TRequest, TResponse>
where TRequest : ICancellableAsyncRequest<TResponse>
{
private readonly ICancellableAsyncRequestHandler<TRequest, TResponse> _inner;
private readonly IPostRequestHandler<TRequest, TResponse>[] _postHandlers;
public Pipeline(
ICancellableAsyncRequestHandler<TRequest, TResponse> inner,
IPostRequestHandler<TRequest, TResponse>[] postHandlers
)
{
_inner = inner;
_postHandlers = postHandlers;
}
public async Task<TResponse> Handle(TRequest message, CancellationToken cancellationToken)
{
var response = await _inner.Handle(message, cancellationToken);
foreach (var postHandler in _postHandlers)
{
postHandler.Handle(message, response);
}
return response;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment