From 1108009fec7783c6acafd7490899c6e7d93fb75a Mon Sep 17 00:00:00 2001 From: emorell96 Date: Tue, 23 Mar 2021 23:19:38 -0700 Subject: [PATCH] removed the extensions from here into a sample to avoid adding 2 new dependencies. --- .../Extensions/ServiceCollectionExtensions.cs | 50 ------------------- 1 file changed, 50 deletions(-) delete mode 100644 src/Discord.Net.Rest/Extensions/ServiceCollectionExtensions.cs diff --git a/src/Discord.Net.Rest/Extensions/ServiceCollectionExtensions.cs b/src/Discord.Net.Rest/Extensions/ServiceCollectionExtensions.cs deleted file mode 100644 index 7b4123145..000000000 --- a/src/Discord.Net.Rest/Extensions/ServiceCollectionExtensions.cs +++ /dev/null @@ -1,50 +0,0 @@ -using Microsoft.Extensions.DependencyInjection; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Net.Http; -using System.Net; -using Discord.Net.Rest; -using Discord.Rest.Net; - -namespace Discord.Rest.Extensions -{ - /// - /// Here you will find all the extensions to be able to add a Discord Client to an IServiceCollection - /// - public static class ServiceCollectionExtensions - { - /// - /// Adds the DiscordRestClient as a Scoped Service to be able to use through DI. - /// - /// This is the IServiceCollection where all the services are located. - /// Set this to true to use proxies, default is false. - /// - public static IServiceCollection AddDiscordRestClient(this IServiceCollection services, bool useProxy = false) - { - services.AddHttpClient("HttpClientFactoryRestClientProvider") - .ConfigurePrimaryHttpMessageHandler(() => new HttpClientHandler - { - AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip, - UseCookies = false, - UseProxy = useProxy, - }); - - - - //services.AddScoped(provider => new HttpClientFactoryRestClientProvider(provider.GetRequiredService())); - services.AddSingleton(provider => - { - var config = new DiscordRestConfig - { - RestClientProvider = url => new HttpClientFactoryRestClient(url, provider.GetRequiredService().CreateClient("HttpClientFactoryRestClientProvider"), useProxy) - }; - return new DiscordRestClient(config); - }); - - return services; - } - } -}