Created
November 18, 2016 01:52
-
-
Save dcomartin/f9976784734d7251e2cce5e0823df61e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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