添加GC-DOWNLOAD项目
This commit is contained in:
1 parent
c95dfaf9f3
commit
791db4fe12
47 files changed
+869
-313
No files matched your search
@@ -0,0 +1,50 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using GC.Models;
|
||||
using GC.Services;
|
||||
|
||||
namespace GC.Download;
|
||||
|
||||
public sealed class DownloadModuleFactory : IDownloadModuleFactory
|
||||
{
|
||||
public IDownloadModule Create(AppPaths paths, SettingsService settings, ModelRepository models) =>
|
||||
new DownloadModule(paths, settings, models);
|
||||
|
||||
public bool TryApplyPending(AppPaths paths) => LauncherUpdater.TryApplyPending(paths);
|
||||
}
|
||||
|
||||
internal sealed class DownloadModule : IDownloadModule
|
||||
{
|
||||
public IDownloadCenter Downloads { get; }
|
||||
public IModelSourceClient Sources { get; }
|
||||
public IUpdateService Updates { get; }
|
||||
public ISourceSelector Selector { get; }
|
||||
public ILauncherUpdateService LauncherUpdates { get; }
|
||||
|
||||
public DownloadModule(AppPaths paths, SettingsService settings, ModelRepository models)
|
||||
{
|
||||
Sources = new ModelSourceClient(paths);
|
||||
Downloads = new DownloadCenter(paths, models);
|
||||
Selector = new SourceSelector();
|
||||
Updates = new UpdateService(paths, settings, UpdateService.CreateRemote(settings.Current));
|
||||
LauncherUpdates = new LauncherUpdateService();
|
||||
}
|
||||
|
||||
public IModelRemote CreateRemote(SourcePreset preset) => SourceSelector.CreateRemote(preset);
|
||||
}
|
||||
|
||||
internal sealed class LauncherUpdateService : ILauncherUpdateService
|
||||
{
|
||||
public Task<string?> CheckAsync(IModelRemote remote, CancellationToken ct = default) =>
|
||||
LauncherUpdater.CheckAsync(remote, ct);
|
||||
|
||||
public Task<UpdateRunResult> DownloadAsync(AppPaths paths, IModelRemote remote,
|
||||
IProgress<UpdateProgressInfo>? progress = null, CancellationToken ct = default) =>
|
||||
LauncherUpdater.DownloadAsync(paths, remote, progress, ct);
|
||||
|
||||
public bool ScheduleApply(AppPaths paths, string packageName) =>
|
||||
LauncherUpdater.ScheduleApply(paths, packageName);
|
||||
|
||||
public bool TryApplyPending(AppPaths paths) => LauncherUpdater.TryApplyPending(paths);
|
||||
}
|
||||
Reference in new issue
Block a user