| | | 1 | | // Copyright (c) ZeroC, Inc. |
| | | 2 | | |
| | | 3 | | using IceRpc.Compressor; |
| | | 4 | | using System.IO.Compression; |
| | | 5 | | |
| | | 6 | | namespace IceRpc.Extensions.DependencyInjection; |
| | | 7 | | |
| | | 8 | | /// <summary>Provides an extension method for <see cref="IInvokerBuilder" /> to add the compressor interceptor. |
| | | 9 | | /// </summary> |
| | | 10 | | public static class CompressorInvokerBuilderExtensions |
| | | 11 | | { |
| | | 12 | | /// <summary>Adds a <see cref="CompressorInterceptor" /> to this invoker builder.</summary> |
| | | 13 | | /// <param name="builder">The builder being configured.</param> |
| | | 14 | | /// <param name="compressionFormat">The compression format for the compress operation.</param> |
| | | 15 | | /// <param name="compressionLevel">The compression level for the compress operation.</param> |
| | | 16 | | /// <returns>The builder being configured.</returns> |
| | | 17 | | public static IInvokerBuilder UseCompressor( |
| | | 18 | | this IInvokerBuilder builder, |
| | | 19 | | CompressionFormat compressionFormat, |
| | | 20 | | CompressionLevel compressionLevel = CompressionLevel.Fastest) => |
| | 4 | 21 | | builder.Use(next => new CompressorInterceptor(next, compressionFormat, compressionLevel)); |
| | | 22 | | } |