@@ -17,9 +17,12 @@ namespace SimpleFeedReader;
17
17
/// When true, the <see cref="FeedReader"/> will throw on errors, when false the <see cref="FeedReader"/> will
18
18
/// suppress exceptions and return empty results.
19
19
/// </param>
20
- public class FeedReader ( IFeedItemNormalizer defaultFeedItemNormalizer , bool throwOnError ) : IFeedReader
20
+ /// <param name="httpClient">
21
+ /// When you want to use a custom <see cref="HttpClient"/> you can set it through here.
22
+ /// </param>
23
+ public class FeedReader ( IFeedItemNormalizer defaultFeedItemNormalizer , bool throwOnError , HttpClient ? httpClient = null ) : IFeedReader
21
24
{
22
- private static readonly HttpClient _httpclient = new ( ) ;
25
+ private readonly HttpClient _httpclient = httpClient ?? new ( ) ;
23
26
24
27
/// <summary>
25
28
/// Gets the default FeedItemNormalizer the <see cref="FeedReader"/> will use when normalizing
@@ -36,8 +39,11 @@ public class FeedReader(IFeedItemNormalizer defaultFeedItemNormalizer, bool thro
36
39
/// <summary>
37
40
/// Initializes a new instance of the <see cref="FeedReader"/> class.
38
41
/// </summary>
39
- public FeedReader ( )
40
- : this ( new DefaultFeedItemNormalizer ( ) ) { }
42
+ /// <param name="httpClient">
43
+ /// When you want to use a custom <see cref="HttpClient"/> you can set it through here.
44
+ /// </param>
45
+ public FeedReader ( HttpClient ? httpClient = null )
46
+ : this ( new DefaultFeedItemNormalizer ( ) , httpClient ) { }
41
47
42
48
/// <summary>
43
49
/// Initializes a new instance of the <see cref="FeedReader"/> class.
@@ -46,17 +52,23 @@ public FeedReader()
46
52
/// When true, the <see cref="FeedReader"/> will throw on errors, when false the <see cref="FeedReader"/> will
47
53
/// suppress exceptions and return empty results.
48
54
/// </param>
49
- public FeedReader ( bool throwOnError )
50
- : this ( new DefaultFeedItemNormalizer ( ) , throwOnError ) { }
55
+ /// <param name="httpClient">
56
+ /// When you want to use a custom <see cref="HttpClient"/> you can set it through here.
57
+ /// </param>
58
+ public FeedReader ( bool throwOnError , HttpClient ? httpClient = null )
59
+ : this ( new DefaultFeedItemNormalizer ( ) , throwOnError , httpClient ) { }
51
60
52
61
/// <summary>
53
62
/// Initializes a new instance of the <see cref="FeedReader"/> class.
54
63
/// </summary>
55
64
/// <param name="defaultFeedItemNormalizer">
56
65
/// The <see cref="IFeedItemNormalizer"/> to use when normalizing <see cref="SyndicationItem"/>s.
57
66
/// </param>
58
- public FeedReader ( IFeedItemNormalizer defaultFeedItemNormalizer )
59
- : this ( defaultFeedItemNormalizer , false ) { }
67
+ /// <param name="httpClient">
68
+ /// When you want to use a custom <see cref="HttpClient"/> you can set it through here.
69
+ /// </param>
70
+ public FeedReader ( IFeedItemNormalizer defaultFeedItemNormalizer , HttpClient ? httpClient = null )
71
+ : this ( defaultFeedItemNormalizer , false , httpClient ) { }
60
72
61
73
/// <inheritdoc/>
62
74
public Task < IEnumerable < FeedItem > > RetrieveFeedsAsync ( IEnumerable < string > uris , CancellationToken cancellationToken = default )
@@ -126,7 +138,7 @@ public Task<IEnumerable<FeedItem>> RetrieveFeedAsync(XmlReader xmlReader, IFeedI
126
138
return Task . FromResult ( Enumerable . Empty < FeedItem > ( ) ) ;
127
139
}
128
140
129
- private static async Task < XmlReader > GetXmlReaderAsync ( string uri , CancellationToken cancellationToken = default )
141
+ private async Task < XmlReader > GetXmlReaderAsync ( string uri , CancellationToken cancellationToken = default )
130
142
{
131
143
if ( Uri . IsWellFormedUriString ( uri , UriKind . Absolute ) )
132
144
{
0 commit comments