| | 1 | | // Copyright (c) ZeroC, Inc. |
| | 2 | |
|
| | 3 | | using IceRpc.Features; |
| | 4 | |
|
| | 5 | | namespace IceRpc; |
| | 6 | |
|
| | 7 | | /// <summary>Provides an extension method for <see cref="Pipeline" /> to add an interceptor that sets a feature in all |
| | 8 | | /// requests.</summary> |
| | 9 | | public static class FeaturePipelineExtensions |
| | 10 | | { |
| | 11 | | /// <summary>Adds an interceptor that sets a feature in all requests.</summary> |
| | 12 | | /// <typeparam name="TFeature">The type of the feature.</typeparam> |
| | 13 | | /// <param name="pipeline">The pipeline being configured.</param> |
| | 14 | | /// <param name="feature">The value of the feature to set.</param> |
| | 15 | | /// <returns>The pipeline being configured.</returns> |
| | 16 | | public static Pipeline UseFeature<TFeature>(this Pipeline pipeline, TFeature feature) => |
| 4 | 17 | | pipeline.Use(next => new InlineInvoker((request, cancellationToken) => |
| 2 | 18 | | { |
| 2 | 19 | | request.Features = request.Features.With(feature); |
| 2 | 20 | | return next.InvokeAsync(request, cancellationToken); |
| 6 | 21 | | })); |
| | 22 | | } |