| | | 1 | | // Copyright (c) ZeroC, Inc. |
| | | 2 | | |
| | | 3 | | namespace IceRpc; |
| | | 4 | | |
| | | 5 | | /// <summary>Adapts a function to the <see cref="IInvoker" /> interface.</summary> |
| | | 6 | | public class InlineInvoker : IInvoker |
| | | 7 | | { |
| | | 8 | | private readonly Func<OutgoingRequest, CancellationToken, Task<IncomingResponse>> _function; |
| | | 9 | | |
| | | 10 | | /// <summary>Constructs an <see cref="InlineInvoker" /> using a function.</summary> |
| | | 11 | | /// <param name="function">The function that implements the invoker's InvokerAsync method.</param> |
| | 87 | 12 | | public InlineInvoker(Func<OutgoingRequest, CancellationToken, Task<IncomingResponse>> function) => |
| | 87 | 13 | | _function = function; |
| | | 14 | | |
| | | 15 | | /// <inheritdoc/> |
| | | 16 | | public Task<IncomingResponse> InvokeAsync(OutgoingRequest request, CancellationToken cancellationToken = default) => |
| | 101 | 17 | | _function(request, cancellationToken); |
| | | 18 | | } |