Refactor data providers and update abstractions

- Removed obsolete data providers: `AnchorCollectionDataProvider`, `ContentsDataProvider`, and others, consolidating logic into new composable providers.
- Added `ComposeDataProviders`, `SelectDataProvider`, and `RelationalDataProvider` for improved flexibility and reusability.
- Introduced `IManySelectionComposableDataProvider` interface to support multiple-node selection.
- Enhanced `UnitDownloader` with more robust progress tracking.
- Updated package references and project dependencies for consistency.
- Improved error handling in `StealthConfig` initialization for better fallback on browser drivers.
- Incremented project version to 2.4.5.
This commit is contained in:
qwsdcvghyu89
2025-11-14 03:41:13 +11:00
parent 2958a26e4f
commit 18c5ad83da
27 changed files with 510 additions and 248 deletions
+3 -2
View File
@@ -3,12 +3,14 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Net.Http.Json;
using System.Text;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
namespace Beam {
namespace Beam.Api;
public class ApiCall(HttpClient client, string uri, HttpMethod method, KeyValuePair<string, string[]>[] headers, object? requestData, object? body, params HashSet<HttpStatusCode> successCodes) {
public HttpClient Client { get; } = client;
public object? RequestData { get; } = requestData;
@@ -63,4 +65,3 @@ namespace Beam {
public static async Task<ApiResponse> Get(HttpClient client, string url, ILoggerFactory factory)
=> await new ApiCall(client, url, HttpMethod.Get, [], null, null).GetResponse(factory.CreateLogger<ApiResponse>());
}
}
+3 -2
View File
@@ -2,11 +2,12 @@
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Reflection.PortableExecutable;
using System.Text;
using System.Threading.Tasks;
namespace Beam {
namespace Beam.Api;
public class ApiCallBuilder(HttpClient client) {
HttpClient Client = client;
string Uri;
@@ -77,4 +78,4 @@ namespace Beam {
return new ApiCall(Client, Uri, Method, Headers.Select((x) => new KeyValuePair<string, string[]>(x.Key, x.Value.ToArray())).ToArray(), Data, Body, SuccessCodes);
}
}
}
+8 -2
View File
@@ -1,9 +1,15 @@
// ApiCalls.cs
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
namespace Beam {
namespace Beam.Api;
/// <summary>
/// Executes a batch of <see cref="ApiCall"/>s using either sequential or parallel strategy.
/// </summary>
@@ -45,4 +51,4 @@ namespace Beam {
return bag.OrderBy(x => x.idx).Select(x => x.res).ToList();
}
}
}
+5 -3
View File
@@ -1,7 +1,10 @@
// ApiCallsBuilder.cs
using System;
using System.Collections.Generic;
using System.Net;
namespace Beam {
namespace Beam.Api;
/// <summary>
/// Fluent builder for <see cref="ApiCalls"/>.
/// </summary>
@@ -43,5 +46,4 @@ namespace Beam {
throw new InvalidOperationException("At least one ApiCall is required.");
return new ApiCalls(_calls, _parallelism);
}
}
}
}
+7 -3
View File
@@ -1,10 +1,15 @@
using Microsoft.Extensions.Logging;
using System;
using System.IO;
using Microsoft.Extensions.Logging;
using System.Net;
using System.Net.Http;
using System.Net.Http.Json;
using System.Text;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
namespace Beam {
namespace Beam.Api;
/// <summary>
/// Wrapper that lets the response body be read any number of times (even concurrently).
/// </summary>
@@ -78,5 +83,4 @@ namespace Beam {
if (!Is200) Logger?.LogWarning("Non-success response; attempting to read content.");
return Task.FromResult<Stream>(new MemoryStream(_buffer, writable: false));
}
}
}
+1 -1
View File
@@ -7,7 +7,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging" Version="10.0.0-rc.1.25451.107" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="9.0.9" />
</ItemGroup>
<ItemGroup>