public virtual void SetCurrentPackage(SearchResultPackageMetadata searchResultPackage) { _searchResultPackage = searchResultPackage; OnPropertyChanged("Id"); OnPropertyChanged("IconUrl"); _allPackages = searchResultPackage.Versions.Select(v => v.Version).ToList(); CreateActions(); }
public virtual void SetCurrentPackage(SearchResultPackageMetadata searchResultPackage) { _searchResultPackage = searchResultPackage; OnPropertyChanged("Id"); OnPropertyChanged("IconUrl"); _allPackages = searchResultPackage.Versions.Select(v => v.Version).ToList(); CreateActions(); }
// Returns the package status for the searchPackageResult private PackageStatus CalculatePackageStatus(SearchResultPackageMetadata searchPackageResult) { if (_installedPackageIds.Contains(searchPackageResult.Id)) { var highestAvailableVersion = searchPackageResult.Versions .Select(v => v.Version) .Max(); var highestInstalled = _installedPackages .Where(p => StringComparer.OrdinalIgnoreCase.Equals(p.Id, searchPackageResult.Id)) .OrderByDescending(p => p.Version, VersionComparer.Default) .First(); if (VersionComparer.VersionRelease.Compare(highestInstalled.Version, highestAvailableVersion) < 0) { return(PackageStatus.UpdateAvailable); } return(PackageStatus.Installed); } return(PackageStatus.NotInstalled); }
public override void SetCurrentPackage(SearchResultPackageMetadata searchResultPackage) { base.SetCurrentPackage(searchResultPackage); UpdateInstalledVersion(); }
public override void SetCurrentPackage(SearchResultPackageMetadata searchResultPackage) { base.SetCurrentPackage(searchResultPackage); UpdateInstalledVersion(); }
// Returns the package status for the searchPackageResult private PackageStatus CalculatePackageStatus(SearchResultPackageMetadata searchPackageResult) { if (_installedPackageIds.Contains(searchPackageResult.Id)) { var highestAvailableVersion = searchPackageResult.Versions .Select(v => v.Version) .Max(); var highestInstalled = _installedPackages .Where(p => StringComparer.OrdinalIgnoreCase.Equals(p.Id, searchPackageResult.Id)) .OrderByDescending(p => p.Version, VersionComparer.Default) .First(); if (VersionComparer.VersionRelease.Compare(highestInstalled.Version, highestAvailableVersion) < 0) { return PackageStatus.UpdateAvailable; } return PackageStatus.Installed; } return PackageStatus.NotInstalled; }
public async Task<LoadResult> LoadItems(int startIndex, CancellationToken ct) { ct.ThrowIfCancellationRequested(); List<SearchResultPackageMetadata> packages = new List<SearchResultPackageMetadata>(); var results = await Search(startIndex, ct); int resultCount = 0; foreach (var package in results) { ct.ThrowIfCancellationRequested(); ++resultCount; var searchResultPackage = new SearchResultPackageMetadata(_sourceRepository); searchResultPackage.Id = package.Identity.Id; searchResultPackage.Version = package.Identity.Version; searchResultPackage.IconUrl = package.IconUrl; // get other versions var versionList = package.Versions.ToList(); if (!_option.IncludePrerelease) { // remove prerelease version if includePrelease is false versionList.RemoveAll(v => v.Version.IsPrerelease); } if (!versionList.Select(v => v.Version).Contains(searchResultPackage.Version)) { versionList.Add(new VersionInfo(searchResultPackage.Version, 0)); } searchResultPackage.Versions = versionList; searchResultPackage.Status = CalculatePackageStatus(searchResultPackage); // filter out prerelease version when needed. if (searchResultPackage.Version.IsPrerelease && !_option.IncludePrerelease && searchResultPackage.Status == PackageStatus.NotInstalled) { continue; } if (_option.Filter == Filter.UpdatesAvailable && searchResultPackage.Status != PackageStatus.UpdateAvailable) { continue; } searchResultPackage.Summary = package.Summary; packages.Add(searchResultPackage); } ct.ThrowIfCancellationRequested(); return new LoadResult() { Items = packages, HasMoreItems = resultCount != 0, NextStartIndex = startIndex + resultCount }; }
public async Task <LoadResult> LoadItems(int startIndex, CancellationToken ct) { ct.ThrowIfCancellationRequested(); List <SearchResultPackageMetadata> packages = new List <SearchResultPackageMetadata>(); var results = await Search(startIndex, ct); int resultCount = 0; foreach (var package in results) { ct.ThrowIfCancellationRequested(); ++resultCount; var searchResultPackage = new SearchResultPackageMetadata(_sourceRepository); searchResultPackage.Id = package.Identity.Id; searchResultPackage.Version = package.Identity.Version; searchResultPackage.IconUrl = package.IconUrl; // get other versions var versionList = package.Versions.ToList(); if (!_option.IncludePrerelease) { // remove prerelease version if includePrelease is false versionList.RemoveAll(v => v.Version.IsPrerelease); } if (!versionList.Select(v => v.Version).Contains(searchResultPackage.Version)) { versionList.Add(new VersionInfo(searchResultPackage.Version, 0)); } searchResultPackage.Versions = versionList; searchResultPackage.Status = CalculatePackageStatus(searchResultPackage); // filter out prerelease version when needed. if (searchResultPackage.Version.IsPrerelease && !_option.IncludePrerelease && searchResultPackage.Status == PackageStatus.NotInstalled) { continue; } if (_option.Filter == Filter.UpdatesAvailable && searchResultPackage.Status != PackageStatus.UpdateAvailable) { continue; } searchResultPackage.Summary = package.Summary; packages.Add(searchResultPackage); } ct.ThrowIfCancellationRequested(); return(new LoadResult() { Items = packages, HasMoreItems = resultCount != 0, NextStartIndex = startIndex + resultCount }); }