private async Task LoadAvailablePackagesAsync() { await TaskUtilities.SwitchToBackgroundThread(); var vmAvailablePackages = new List <IRPackageViewModel>(); var availablePackages = await _packageManager.GetAvailablePackagesAsync(); var installedPackages = _installedPackages.ToDictionary(p => p.Name, p => p); foreach (var package in availablePackages) { IRPackageViewModel installedPackage; if (installedPackages.TryGetValue(package.Package, out installedPackage)) { installedPackage.UpdateAvailablePackageDetails(package); vmAvailablePackages.Add(installedPackage); } else { vmAvailablePackages.Add(RPackageViewModel.CreateAvailable(package, this)); } } _availablePackages = vmAvailablePackages.OrderBy(p => p.Name).ToList(); }
private async Task LoadInstalledAndAvailablePackagesAsync() { await TaskUtilities.SwitchToBackgroundThread(); var availablePackages = await _packageManager.GetAvailablePackagesAsync(); var installedPackages = await _packageManager.GetInstalledPackagesAsync(); var vmAvailablePackages = availablePackages.Select(RPackageViewModel.CreateAvailable).ToDictionary(p => p.Name); var vmInstalledPackages = new List <IRPackageViewModel>(); foreach (var installedPackage in installedPackages) { RPackageViewModel vmPackage; if (vmAvailablePackages.TryGetValue(installedPackage.Package, out vmPackage)) { vmPackage.AddDetails(installedPackage, true); vmInstalledPackages.Add(vmPackage); } else { vmInstalledPackages.Add(RPackageViewModel.CreateInstalled(installedPackage)); } } _installedPackages = vmInstalledPackages.OrderBy(p => p.Name).ToList(); _availablePackages = vmAvailablePackages.Values.OrderBy(p => p.Name).ToList <IRPackageViewModel>(); }