Skip to content

Commit 05842dc

Browse files
committed
Add code docs
1 parent 7c4823e commit 05842dc

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

HttpClientFactory/CachedHttpClientFactory.cs

+12
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,26 @@
22

33
namespace HttpClientFactory;
44

5+
/// <summary>
6+
/// Represents a cached implementation of the IHttpClientFactory interface.
7+
/// </summary>
58
public class CachedHttpClientFactory : IHttpClientFactory
69
{
710
private readonly IHttpClientFactory _httpClientFactory;
811
private readonly Dictionary<int, HttpClient> _cache = new();
912

13+
/// <summary>
14+
/// Initializes a new instance of the CachedHttpClientFactory class with the specified IHttpClientFactory implementation.
15+
/// </summary>
16+
/// <param name="httpClientFactory">An instance of IHttpClientFactory used to create HttpClient instances.</param>
1017
public CachedHttpClientFactory(IHttpClientFactory httpClientFactory) =>
1118
_httpClientFactory = httpClientFactory;
1219

20+
/// <summary>
21+
/// Creates an HttpClient instance with the specified web proxy. If the same web proxy has been used before, a cached instance will be returned.
22+
/// </summary>
23+
/// <param name="webProxy">The web proxy to be used by the HttpClient.</param>
24+
/// <returns>An instance of HttpClient configured with the provided web proxy.</returns>
1325
public HttpClient CreateClientWithProxy(IWebProxy webProxy)
1426
{
1527
var key = webProxy.GetHashCode();

HttpClientFactory/HClientFactory.cs

+12
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,25 @@
22

33
namespace HttpClientFactory;
44

5+
/// <summary>
6+
/// Represents a concrete implementation of the IHttpClientFactory interface.
7+
/// </summary>
58
public class HClientFactory : IHttpClientFactory
69
{
710
private readonly Func<HttpClientHandler> _makeHandler;
811

12+
/// <summary>
13+
/// Initializes a new instance of the HClientFactory class with the specified HttpClientHandler factory function.
14+
/// </summary>
15+
/// <param name="makeHandler">A factory function that creates instances of HttpClientHandler.</param>
916
public HClientFactory(Func<HttpClientHandler> makeHandler) =>
1017
_makeHandler = makeHandler;
1118

19+
/// <summary>
20+
/// Creates an HttpClient instance with the specified web proxy.
21+
/// </summary>
22+
/// <param name="webProxy">The web proxy to be used by the HttpClient.</param>
23+
/// <returns>An instance of HttpClient configured with the provided web proxy.</returns>
1224
public HttpClient CreateClientWithProxy(IWebProxy webProxy)
1325
{
1426
var handler = _makeHandler();

HttpClientFactory/IHttpClientFactory.cs

+8
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,15 @@
22

33
namespace HttpClientFactory;
44

5+
/// <summary>
6+
/// Represents a factory for creating HttpClient instances.
7+
/// </summary>
58
public interface IHttpClientFactory
69
{
10+
/// <summary>
11+
/// Creates an HttpClient instance with the specified web proxy.
12+
/// </summary>
13+
/// <param name="webProxy">The web proxy to be used by the HttpClient.</param>
14+
/// <returns>An instance of HttpClient configured with the provided web proxy.</returns>
715
HttpClient CreateClientWithProxy(IWebProxy webProxy);
816
}

0 commit comments

Comments
 (0)