private IEnumerable <LauncherUpdaterItem> GetUpdaterItems(IEnumerable <IComponent> components) { if (components is null) { throw new ArgumentNullException(nameof(components)); } var pendingComponents = components.ToList(); foreach (var pendingComponent in pendingComponents) { var item = new LauncherUpdaterItem(); var componentFilePath = pendingComponent.GetFilePath(); switch (pendingComponent.RequiredAction) { case ComponentAction.Keep: continue; case ComponentAction.Delete: item.File = componentFilePath; item.Destination = null; break; case ComponentAction.Update: ComponentDownloadPathStorage.Instance.TryGetValue(pendingComponent, out var file); item.File = file; item.Destination = componentFilePath; break; } item.BackupDestination = componentFilePath; BackupManager.Instance.TryGetValue(pendingComponent, out var backup); item.Backup = backup; yield return(item); } var completedComponents = AllComponents.Except(pendingComponents).ToList(); foreach (var completedComponent in completedComponents) { if (completedComponent.RequiredAction == ComponentAction.Keep) { continue; } var item = new LauncherUpdaterItem { BackupDestination = completedComponent.GetFilePath() }; BackupManager.Instance.TryGetValue(completedComponent, out var backup); if (!string.IsNullOrEmpty(backup)) { item.Backup = backup; } yield return(item); } }