A small helper class intended to download a file with progress reporting. It declares a progress delegate and an event, a constructor taking a URL and destination path, a StartDownload method that would begin the download, and implements IDisposable.
#nullable enable annotations
namespace LichessNET.Database;
internal class HttpClientDownloadWithProgress : IDisposable
{
public delegate void ProgressChangedHandler(long? totalFileSize, long totalBytesDownloaded,
double? progressPercentage);
public HttpClientDownloadWithProgress(string downloadUrl, string destinationFilePath)
{
}
public event ProgressChangedHandler ProgressChanged;
public Task StartDownload()
{
ProgressChanged?.Invoke(0, 0, 0);
throw new NotSupportedException("Lichess database file downloads are disabled in the whitelist-safe s&box port.");
}
public void Dispose()
{
}
}