wabbajack/Wabbajack.Lib/StatusMessages/ManuallyDownloadFile.cs

39 lines
1.1 KiB
C#
Raw Normal View History

2020-02-11 00:30:38 +00:00
using System;
using System.Net.Http;
using System.Threading.Tasks;
using Wabbajack.Common;
using Wabbajack.Lib.Downloaders;
namespace Wabbajack.Lib
{
2020-02-11 00:30:38 +00:00
public class ManuallyDownloadFile : AUserIntervention
{
2020-02-11 00:30:38 +00:00
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;
2020-02-11 00:30:38 +00:00
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)
2020-02-11 00:30:38 +00:00
{
_tcs.SetResult((s, client));
}
}
}