You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
1.1 KiB
33 lines
1.1 KiB
using StabilityMatrix.Core.Models.Progress; |
|
using StabilityMatrix.Core.Services; |
|
|
|
namespace StabilityMatrix.Core.Models.PackageModification; |
|
|
|
public class AddInstalledPackageStep : IPackageStep |
|
{ |
|
private readonly ISettingsManager settingsManager; |
|
private readonly InstalledPackage newInstalledPackage; |
|
|
|
public AddInstalledPackageStep( |
|
ISettingsManager settingsManager, |
|
InstalledPackage newInstalledPackage |
|
) |
|
{ |
|
this.settingsManager = settingsManager; |
|
this.newInstalledPackage = newInstalledPackage; |
|
} |
|
|
|
public async Task ExecuteAsync(IProgress<ProgressReport>? progress = null) |
|
{ |
|
if (!string.IsNullOrWhiteSpace(newInstalledPackage.DisplayName)) |
|
{ |
|
settingsManager.PackageInstallsInProgress.Remove(newInstalledPackage.DisplayName); |
|
} |
|
|
|
await using var transaction = settingsManager.BeginTransaction(); |
|
transaction.Settings.InstalledPackages.Add(newInstalledPackage); |
|
transaction.Settings.ActiveInstalledPackageId = newInstalledPackage.Id; |
|
} |
|
|
|
public string ProgressTitle => $"{newInstalledPackage.DisplayName} Installed"; |
|
}
|
|
|