-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSurgeProgress.cs
More file actions
71 lines (60 loc) · 2.42 KB
/
SurgeProgress.cs
File metadata and controls
71 lines (60 loc) · 2.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
using System;
namespace Surge
{
/// <summary>
/// Phases of an update operation reported through progress callbacks.
/// </summary>
public enum SurgeProgressPhase
{
Check = 0,
Download = 1,
Verify = 2,
Extract = 3,
ApplyDelta = 4,
Finalize = 5
}
/// <summary>
/// Snapshot of update progress at a point in time.
/// </summary>
public readonly struct SurgeProgress
{
/// <summary>Current phase of the update operation.</summary>
public SurgeProgressPhase Phase { get; init; }
/// <summary>Percent complete within the current phase (0-100).</summary>
public int PhasePercent { get; init; }
/// <summary>Overall percent complete across all phases (0-100).</summary>
public int TotalPercent { get; init; }
/// <summary>Bytes processed so far in the current operation.</summary>
public long BytesDone { get; init; }
/// <summary>Total bytes expected in the current operation.</summary>
public long BytesTotal { get; init; }
/// <summary>Items (files) processed so far.</summary>
public long ItemsDone { get; init; }
/// <summary>Total items (files) expected.</summary>
public long ItemsTotal { get; init; }
/// <summary>Current transfer speed in bytes per second.</summary>
public double SpeedBytesPerSec { get; init; }
}
/// <summary>
/// Interface for receiving progress notifications during update operations.
/// </summary>
public interface ISurgeProgressSource
{
Action<SurgeProgress>? DownloadProgress { get; set; }
Action<SurgeProgress>? VerifyProgress { get; set; }
Action<SurgeProgress>? ExtractProgress { get; set; }
Action<SurgeProgress>? ApplyDeltaProgress { get; set; }
Action<SurgeProgress>? TotalProgress { get; set; }
}
/// <summary>
/// Default implementation of <see cref="ISurgeProgressSource"/> with settable callbacks.
/// </summary>
public sealed class SurgeProgressSource : ISurgeProgressSource
{
public Action<SurgeProgress>? DownloadProgress { get; set; }
public Action<SurgeProgress>? VerifyProgress { get; set; }
public Action<SurgeProgress>? ExtractProgress { get; set; }
public Action<SurgeProgress>? ApplyDeltaProgress { get; set; }
public Action<SurgeProgress>? TotalProgress { get; set; }
}
}