Philipp Heenemann a8b91f4ee6 Refactor C# code to imperative, top-level statements style
Updated the existing C# code into a more modern, imperative and top-level statements style. This involves shortening the code by removing unnecessary parts like additional brackets and explicit namespace declarations. It's done to improve clarity and readability.
2023-07-12 09:19:33 +02:00

35 lines
987 B
C#

using ReactiveUI;
using SPTInstaller.Controllers;
using SPTInstaller.Helpers;
using SPTInstaller.Interfaces;
using SPTInstaller.Models;
using System.Collections.ObjectModel;
using System.Threading.Tasks;
namespace SPTInstaller.ViewModels;
public class InstallViewModel : ViewModelBase
{
private IProgressableTask _currentTask;
public IProgressableTask CurrentTask
{
get => _currentTask;
set => this.RaiseAndSetIfChanged(ref _currentTask, value);
}
public ObservableCollection<InstallerTaskBase> MyTasks { get; set; } = new(ServiceHelper.GetAll<InstallerTaskBase>());
public InstallViewModel(IScreen host) : base(host)
{
var installer = ServiceHelper.Get<InstallController>();
installer.TaskChanged += (sender, task) => CurrentTask = task;
Task.Run(async () =>
{
var result = await installer.RunTasks();
NavigateTo(new MessageViewModel(HostScreen, result));
});
}
}