Skip to content

Commit a043ac4

Browse files
author
Meyn
committed
Easier access to individual progress and speed reporter
1 parent b133933 commit a043ac4

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

DownloadAssistant/DownloadAssistant.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net6.0</TargetFramework>
4+
<TargetFrameworks>net6.0;net7.0;net8.0;net9.0;</TargetFrameworks>
55
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>enable</Nullable>
77
<Title>DownloadAssistant</Title>

DownloadAssistant/Requests/ExtendedContainer.cs

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,23 @@ public class ExtendedContainer<TRequest> : RequestContainer<TRequest>, IProgress
1313
/// </summary>
1414
public Progress<float> Progress => _progress;
1515
private readonly CombinableProgress _progress = new();
16+
/// <summary>
17+
/// Gets a read-only list of individual progress reporters for each request.
18+
/// </summary>
19+
public IReadOnlyList<Progress<float>> IndividualProgressReporters => _progress.Progressors;
20+
1621

1722
/// <summary>
1823
/// Merged speed reporter of all requests.
1924
/// </summary>
2025
public SpeedReporter<long> SpeedReporter => _speedReporter;
2126
private readonly CombinableSpeedReporter _speedReporter = new();
2227

28+
/// <summary>
29+
/// Gets a read-only list of individual speed reporters for each request.
30+
/// </summary>
31+
public IReadOnlyList<SpeedReporter<long>> IndividualSpeedReporters => _speedReporter.SpeedReporters;
32+
2333
/// <summary>
2434
/// Main constructor for <see cref="ExtendedContainer{TRequest}"/>.
2535
/// </summary>
@@ -50,7 +60,7 @@ public ExtendedContainer() { }
5060
public override void AddRange(params TRequest[] requests)
5161
{
5262
base.AddRange(requests);
53-
foreach (var request in requests)
63+
foreach (TRequest request in requests)
5464
{
5565
AttachProgress(request);
5666
AttachSpeedReporter(request);
@@ -76,7 +86,7 @@ private void AttachSpeedReporter(TRequest request)
7686
public override void Remove(params TRequest[] requests)
7787
{
7888
base.Remove(requests);
79-
foreach (var request in requests)
89+
foreach (TRequest request in requests)
8090
{
8191
if (request is IProgressableRequest progressable && progressable.Progress != null)
8292
_progress?.TryRemove(progressable.Progress);
@@ -100,6 +110,11 @@ private class CombinableSpeedReporter : SpeedReporter<long>
100110
/// </summary>
101111
public int Count => _speedReporters.Count;
102112

113+
/// <summary>
114+
/// Gets a read-only list of attached speed reporters.
115+
/// </summary>
116+
public IReadOnlyList<SpeedReporter<long>> SpeedReporters => _speedReporters;
117+
103118
/// <summary>
104119
/// Initializes a new instance of the <see cref="CombinableSpeedReporter"/> class.
105120
/// </summary>
@@ -193,6 +208,11 @@ private class CombinableProgress : Progress<float>
193208
/// </summary>
194209
public int Count => _progressors.Count;
195210

211+
/// <summary>
212+
/// Gets a read-only list of attached progress reporters.
213+
/// </summary>
214+
public IReadOnlyList<Progress<float>> Progressors => _progressors;
215+
196216
/// <summary>
197217
/// Initializes a new instance of the <see cref="CombinableProgress"/> class.
198218
/// </summary>

0 commit comments

Comments
 (0)