private void UpdateInstalledVersion() { var installed = InstalledPackages.Where(p => StringComparer.OrdinalIgnoreCase.Equals(p.Id, Id)).OrderByDescending(p => p.Version, VersionComparer.Default); if (installed.Any()) { InstalledVersion = string.Format( CultureInfo.CurrentCulture, Resources.Text_InstalledVersion, installed.First().Version.ToNormalizedString()); } else { InstalledVersion = null; } }
protected override void CreateVersions() { _versions = new List <VersionForDisplay>(); var installedVersion = InstalledPackages.Where(p => StringComparer.OrdinalIgnoreCase.Equals(p.Id, Id)).SingleOrDefault(); var allVersions = _allPackages.OrderByDescending(v => v); var latestPrerelease = allVersions.FirstOrDefault(v => v.IsPrerelease); var latestStableVersion = allVersions.FirstOrDefault(v => !v.IsPrerelease); if (SelectedAction == Resources.Action_Uninstall) { _versions.Add(new VersionForDisplay(installedVersion.Version, string.Empty)); } else if (SelectedAction == Resources.Action_Install) { if (latestPrerelease != null && (latestStableVersion == null || latestPrerelease > latestStableVersion)) { _versions.Add(new VersionForDisplay(latestPrerelease, Resources.Version_LatestPrerelease)); } if (latestStableVersion != null) { _versions.Add(new VersionForDisplay(latestStableVersion, Resources.Version_LatestStable)); } // add a separator if (_versions.Count > 0) { _versions.Add(null); } foreach (var version in allVersions) { _versions.Add(new VersionForDisplay(version, string.Empty)); } } else if (SelectedAction == Resources.Action_Upgrade) { if (latestStableVersion != null && latestStableVersion != installedVersion.Version) { _versions.Add(new VersionForDisplay(latestStableVersion, Resources.Version_LatestStable)); // add a separator _versions.Add(null); } foreach (var version in allVersions.Where(v => v > installedVersion.Version)) { _versions.Add(new VersionForDisplay(version, string.Empty)); } } else if (SelectedAction == Resources.Action_Downgrade) { foreach (var version in allVersions.Where(v => v < installedVersion.Version)) { _versions.Add(new VersionForDisplay(version, string.Empty)); } } else { Debug.Fail("Unexpected Action: " + SelectedAction.ToString()); } SelectVersion(); OnPropertyChanged("Versions"); }
public IEnumerable <PackageKey> GetLooseNotIn(IEnumerable <PackageKey> packageKeys) { return(InstalledPackages.Where(i => packageKeys.FirstOrDefault(p => p.LooseEquals(i)) == null)); }