Browse Source

added documentation using .net conventions.

pull/1806/head
emorell96 4 years ago
parent
commit
1d8df45450
2 changed files with 20 additions and 10 deletions
  1. +7
    -0
      src/Discord.Net.Rest/Net/HttpClientFactoryClientProvider.cs
  2. +13
    -10
      src/Discord.Net.Rest/Net/HttpClientFactoryRestClient.cs

+ 7
- 0
src/Discord.Net.Rest/Net/HttpClientFactoryClientProvider.cs View File

@@ -8,12 +8,19 @@ using System.Threading.Tasks;

namespace Discord.Rest.Net
{
/// <summary>
/// This RestClientProvider creates the IRestClient used when using an IHttpClientFactory.
/// </summary>
public class HttpClientFactoryRestClientProvider
{
public readonly RestClientProvider Instance;

private readonly IHttpClientFactory _httpClientFactory;

/// <summary>
/// Constructs the HttpClientFactoryRestClientProvider, the idea is to use this with DI so that the parameters gets fed with the right HttpClientFactory.
/// </summary>
/// <param name="httpClientFactory">This is the IHttpClientFactory used. It should be fed through DI.</param>
public HttpClientFactoryRestClientProvider(IHttpClientFactory httpClientFactory)
{
_httpClientFactory = httpClientFactory;


+ 13
- 10
src/Discord.Net.Rest/Net/HttpClientFactoryRestClient.cs View File

@@ -14,6 +14,9 @@ using System.Threading.Tasks;

namespace Discord.Rest.Net
{
/// <summary>
/// This HttpClientFactoryRestClient is the one used by HttpClientFactoryRestClientProvider. It accepts a preconfigured HttpClient.
/// </summary>
internal sealed class HttpClientFactoryRestClient : IRestClient, IDisposable
{
private const int HR_SECURECHANNELFAILED = -2146233079;
@@ -29,17 +32,17 @@ namespace Discord.Rest.Net
_baseUrl = baseUrl;
//this client would be given to use through DI. The advantage would be that it would be managed by DI, and no socket Exhaustation possible.
_client = httpClient;
//#pragma warning disable IDISP014
// _client = new HttpClient(new HttpClientHandler
// {
// AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate,
// UseCookies = false,
// UseProxy = useProxy,
// });
//#pragma warning restore IDISP014
SetHeader("accept-encoding", "gzip, deflate");
//#pragma warning disable IDISP014
// _client = new HttpClient(new HttpClientHandler
// {
// AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate,
// UseCookies = false,
// UseProxy = useProxy,
// });
//#pragma warning restore IDISP014
SetHeader("accept-encoding", "gzip, deflate"); //I will move this to the Extension method probably in another commit.

_cancelToken = CancellationToken.None;
_cancelToken = CancellationToken.None;
_errorDeserializer = new JsonSerializer();
}
private void Dispose(bool disposing)


Loading…
Cancel
Save