Skip to content

Commit 3fd2de6

Browse files
committed
Removed the duplicate loader
1 parent 42ebfc5 commit 3fd2de6

File tree

3 files changed

+14
-125
lines changed

3 files changed

+14
-125
lines changed

AngleSharp.Io/AngleSharp.Io.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@
5555
<Compile Include="Network\HttpClientRequester.cs" />
5656
<Compile Include="Network\Response.cs" />
5757
<Compile Include="Properties\AssemblyInfo.cs" />
58-
<Compile Include="Services\LoaderService.cs" />
5958
</ItemGroup>
6059
<ItemGroup>
6160
<None Include="packages.config" />
Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
namespace AngleSharp
22
{
33
using AngleSharp.Io.Network;
4-
using AngleSharp.Io.Services;
54
using AngleSharp.Network;
65
using AngleSharp.Network.Default;
7-
using AngleSharp.Services;
8-
using System.Linq;
6+
using AngleSharp.Services.Default;
7+
using System;
98
using System.Net.Http;
109

1110
/// <summary>
@@ -17,37 +16,28 @@ public static class ConfigurationExtensions
1716
/// Adds a loader service that comes with all (improved) requesters.
1817
/// </summary>
1918
/// <param name="configuration">The configuration to use.</param>
19+
/// <param name="setup">Optional setup for the loader service.</param>
2020
/// <returns>The new configuration.</returns>
21-
public static IConfiguration WithRequesters(this IConfiguration configuration)
21+
public static IConfiguration WithRequesters(this IConfiguration configuration, Action<LoaderService> setup = null)
2222
{
23-
if (!configuration.Services.OfType<ILoaderService>().Any())
24-
{
25-
var requesters = new IRequester [] { new HttpClientRequester(), new DataRequester() };
26-
var service = new LoaderService(requesters);
27-
return configuration.With(service);
28-
}
29-
30-
return configuration;
23+
var requesters = new IRequester[] { new HttpClientRequester(), new DataRequester() };
24+
return configuration.WithDefaultLoader(setup, requesters);
3125
}
3226

33-
3427
/// <summary>
3528
/// Adds a loader service that comes with all (improved) requesters.
3629
/// </summary>
3730
/// <param name="configuration">The configuration to use.</param>
38-
/// <param name="httpMessageHandler">The HTTP handler stack to use for sending requests.</param>
31+
/// <param name="httpMessageHandler">
32+
/// The HTTP handler stack to use for sending requests.
33+
/// </param>
34+
/// <param name="setup">Optional setup for the loader service.</param>
3935
/// <returns>The new configuration.</returns>
40-
public static IConfiguration WithHttpRequesters(this IConfiguration configuration, HttpMessageHandler httpMessageHandler)
36+
public static IConfiguration WithRequesters(this IConfiguration configuration, HttpMessageHandler httpMessageHandler, Action<LoaderService> setup = null)
4137
{
42-
if (!configuration.Services.OfType<ILoaderService>().Any())
43-
{
44-
var httpClient = new HttpClient(httpMessageHandler);
45-
var requesters = new IRequester[] { new HttpClientRequester(httpClient), new DataRequester() };
46-
var service = new LoaderService(requesters);
47-
return configuration.With(service);
48-
}
49-
50-
return configuration;
38+
var httpClient = new HttpClient(httpMessageHandler);
39+
var requesters = new IRequester[] { new HttpClientRequester(httpClient), new DataRequester() };
40+
return configuration.WithDefaultLoader(setup, requesters);
5141
}
5242
}
5343
}

AngleSharp.Io/Services/LoaderService.cs

Lines changed: 0 additions & 100 deletions
This file was deleted.

0 commit comments

Comments
 (0)