mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
39 lines
1.1 KiB
C#
39 lines
1.1 KiB
C#
using System;
|
|
using System.Net.Http;
|
|
using System.Threading.Tasks;
|
|
using Wabbajack.Common;
|
|
using Wabbajack.Lib.Downloaders;
|
|
|
|
namespace Wabbajack.Lib
|
|
{
|
|
public class ManuallyDownloadFile : AUserIntervention
|
|
{
|
|
public ManualDownloader.State State { get; }
|
|
public override string ShortDescription { get; }
|
|
public override string ExtendedDescription { get; }
|
|
|
|
private TaskCompletionSource<(Uri, Common.Http.Client)> _tcs = new TaskCompletionSource<(Uri, Common.Http.Client)>();
|
|
public Task<(Uri, Common.Http.Client)> Task => _tcs.Task;
|
|
|
|
private ManuallyDownloadFile(ManualDownloader.State state)
|
|
{
|
|
State = state;
|
|
}
|
|
|
|
public static async Task<ManuallyDownloadFile> Create(ManualDownloader.State state)
|
|
{
|
|
var result = new ManuallyDownloadFile(state);
|
|
return result;
|
|
}
|
|
public override void Cancel()
|
|
{
|
|
_tcs.SetCanceled();
|
|
}
|
|
|
|
public void Resume(Uri s, Common.Http.Client client)
|
|
{
|
|
_tcs.SetResult((s, client));
|
|
}
|
|
}
|
|
}
|