/// <summary> /// If no decompression providers are specified then all is used by default. /// </summary> /// <param name="services">Services to use when instantiating decompression providers.</param> /// <param name="options">The options for this instance.</param> public RequestDecompressionProvider(IServiceProvider services, RequestDecompressionOptions options) { if (services == null) { throw new ArgumentNullException(nameof(services)); } if (options == null) { throw new ArgumentNullException(nameof(options)); } _providers = options.Providers.ToArray(); // If no decompression providers are specified then all is used by default if (_providers.Length == 0) { _providers = GetAllAvailableDecompressionProviders(); } else { for (int i = 0; i < _providers.Length; i++) { var factory = _providers[i] as DecompressionProviderFactory; if (factory != null) { _providers[i] = factory.CreateInstance(services); } } } _logger = services.GetRequiredService <ILogger <RequestDecompressionProvider> >(); }
public static IHoneyCombBuilder AddRequestDecompression(this IHoneyCombBuilder builder, Action <RequestDecompressionOptions> configureOptions = null) { var options = new RequestDecompressionOptions(); configureOptions?.Invoke(options); builder.Services.AddSingleton(options); builder.Services.AddSingleton <IRequestDecompressionProvider, RequestDecompressionProvider>(); return(builder); }