protected void ProductSelected(BChangeEventArgs <BSelectOptionBase <int?> > arg) { Components.Clear(); table.MarkAsRequireRender(); RequireRender = true; if (arg.NewValue.Value.HasValue) { productId = arg.NewValue.Value.Value; productVersions = ProductService.GetProductVersions(arg.NewValue.Value.Value); Versions = productVersions.ToDictionary(x => x.Id, x => x.Version); } else { EmptyMessage = "请选择产品及版本后查询"; productId = 0; productVersions.Clear(); Versions.Clear(); } }
// loads global config public bool Load(string path) { try { XmlDocument config = new XmlDocument(); config.Load(path); LatestUpdate = config.SelectSingleNode("//latestUpdate").Attributes["name"].Value; LatestFullVersion = config.SelectSingleNode("//latestFullVersion").Attributes["name"].Value; if (LatestFullVersion != null && CheckVersionSyntax(LatestFullVersion)) { if (LatestUpdate == null || !CheckVersionSyntax(LatestUpdate)) { LatestUpdate = LatestFullVersion; } Versions.Clear(); foreach (XmlNode node in config.SelectNodes("//version")) { string version = node.Attributes["name"].Value; bool fullVersion = (node.Attributes["fullVersion"].Value == "true"); Add(version, fullVersion); } return(true); } } catch (Exception e) { ErrorLog.Add(this, e.Message); } Clear(); return(false); }
// clears the stored information public void Clear() { Versions.Clear(); LatestUpdate = null; LatestFullVersion = null; }
/// <summary>Read a file containing application details</summary> /// <param name="fileName">File to read</param> /// <exception cref="System.ArgumentNullException"/> /// <exception cref="FileNotFoundException"/> /// <exception cref="IOException"/> public void Read(string fileName) { if (string.IsNullOrEmpty(fileName)) { throw new System.ArgumentNullException(nameof(fileName)); } // Clear dependencies, versions list Dependencies.Clear(); Versions.Clear(); // Test if the file exists if (!File.Exists(fileName)) { throw new FileNotFoundException(null, fileName); } // TODO use another read method (one-time) // Read file content using (XmlTextReader reader = new XmlTextReader(fileName)) { while (reader.Read()) { if (reader.NodeType != XmlNodeType.Element) { continue; } if (string.IsNullOrEmpty(reader.Name)) { continue; } switch (reader.Name.Trim().ToUpperInvariant()) { case "VERSION": System.Version versionNumber; System.Version.TryParse(reader.GetAttribute("num"), out versionNumber); Versions.Add(new Version() { Number = versionNumber }); break; case "ITEM": Versions.Last().Items.Add(new Item() { Text = reader.GetAttribute("type"), Description = reader.GetAttribute("desc") }); break; case "DEPENDENCY": Dependencies.Add(new Dependency() { Name = reader.GetAttribute("name"), Version = reader.GetAttribute("version"), Authors = reader.GetAttribute("authors"), License = reader.GetAttribute("license") }); break; } } } }
public void Clear() { Versions.Clear(); }
protected override Task CreateVersionsAsync(CancellationToken cancellationToken) { // The value will be null if the server does not return any versions. if (_allPackageVersions == null || _allPackageVersions.Count == 0) { return(Task.CompletedTask); } Versions.Clear(); var installedDependency = InstalledPackageDependencies.Where(p => StringComparer.OrdinalIgnoreCase.Equals(p.Id, Id) && p.VersionRange != null && p.VersionRange.HasLowerBound) .OrderByDescending(p => p.VersionRange.MinVersion) .FirstOrDefault(); // installVersion is null if the package is not installed var installedVersion = installedDependency?.VersionRange; List <(NuGetVersion version, bool isDeprecated)> allVersions = _allPackageVersions?.OrderByDescending(v => v.version).ToList(); // null, if no version constraint defined in package.config VersionRange allowedVersions = _projectVersionConstraints.Select(e => e.VersionRange).FirstOrDefault(); // null, if all versions are allowed to be install or update var blockedVersions = new List <NuGetVersion>(allVersions.Count); List <(NuGetVersion version, bool isDeprecated)> allVersionsAllowed; if (allowedVersions == null) { allowedVersions = VersionRange.All; allVersionsAllowed = allVersions; } else { allVersionsAllowed = allVersions.Where(v => allowedVersions.Satisfies(v.version)).ToList(); foreach ((NuGetVersion version, bool isDeprecated) in allVersions) { if (!allVersionsAllowed.Any(a => a.version.Version.Equals(version.Version))) { blockedVersions.Add(version); } } } var latestPrerelease = allVersionsAllowed.FirstOrDefault(v => v.version.IsPrerelease); var latestStableVersion = allVersionsAllowed.FirstOrDefault(v => !v.version.IsPrerelease); // Add installed version if the project is PackageReference if (_nugetProjects.Any() && installedDependency != null && installedDependency.VersionRange != null && _nugetProjects.First().ProjectStyle.Equals(ProjectModel.ProjectStyle.PackageReference)) { VersionRange installedVersionRange = VersionRange.Parse(installedDependency.VersionRange.OriginalString, true); NuGetVersion bestVersion = installedVersionRange.FindBestMatch(allVersionsAllowed.Select(v => v.version)); var deprecationInfo = allVersionsAllowed.FirstOrDefault(v => v.version == bestVersion).isDeprecated; DisplayVersion displayVersion = new DisplayVersion(installedVersionRange, bestVersion, additionalInfo: string.Empty, isDeprecated: deprecationInfo); _versions.Add(displayVersion); } var isInstalledFloatingOrRange = installedVersion != null && installedVersion.IsFloating || (installedVersion?.OriginalString != null && (installedVersion.OriginalString.StartsWith("(", StringComparison.OrdinalIgnoreCase) || installedVersion.OriginalString.StartsWith("[", StringComparison.OrdinalIgnoreCase))); // Add latest prerelease if neeeded if (latestPrerelease.version != null && (latestStableVersion.version == null || latestPrerelease.version > latestStableVersion.version) && (isInstalledFloatingOrRange || !latestPrerelease.version.Equals(installedVersion?.MinVersion))) { VersionRange latestPrereleaseVersionRange = VersionRange.Parse(latestPrerelease.version.ToString(), allowFloating: false); _versions.Add(new DisplayVersion(latestPrereleaseVersionRange, latestPrerelease.version, Resources.Version_LatestPrerelease, isDeprecated: latestPrerelease.isDeprecated)); } // Add latest stable if needed if (latestStableVersion.version != null && (isInstalledFloatingOrRange || !latestStableVersion.version.Equals(InstalledVersion))) { VersionRange latestStableVersionRange = VersionRange.Parse(latestStableVersion.version.ToString(), allowFloating: false); _versions.Add(new DisplayVersion(latestStableVersionRange, latestStableVersion.version, Resources.Version_LatestStable, isDeprecated: latestStableVersion.isDeprecated)); } // add a separator if (_versions.Count > 0) { _versions.Add(null); } // first add all the available versions to be updated foreach (var version in allVersionsAllowed) { var installed = version.version.Equals(InstalledVersion); var autoReferenced = false; if (installed && _projectVersionConstraints.Any(e => e.IsAutoReferenced && e.VersionRange?.Satisfies(version.version) == true)) { // do not allow auto referenced packages autoReferenced = true; } VersionRange versionRange = VersionRange.Parse(version.version.ToString(), allowFloating: false); _versions.Add(new DisplayVersion(versionRange, version.version, additionalInfo: null, isCurrentInstalled: installed, autoReferenced: autoReferenced, isDeprecated: version.isDeprecated)); } // Disable controls if this is an auto referenced package. SetAutoReferencedCheck(InstalledVersion); // Add disabled versions AddBlockedVersions(blockedVersions); var latestVersion = latestPrerelease.version > latestStableVersion.version ? latestPrerelease.version : latestStableVersion.version; SelectVersion(latestVersion); return(Task.CompletedTask); }
// Synchronize remote and local data public void synchronizeData() { Versions.Clear(); RunnableVersions.Clear(); VsixVersion = null; // If we don't have the remote list, build from the local package list var packageList = serverPackages; if (packageList.IsEmpty()) { packageList = localPackages; } // Group packages by Major.Minor revision var majorMinorPkg = packageList.GroupBy(p => p.Version.Version.Major, p => p); foreach (var major in majorMinorPkg) { var majorVersion = major.Key; var minorPkg = major.GroupBy(p => p.Version.Version.Minor, p => p); foreach (var minor in minorPkg) { var latestPackage = minor.First(); var sdkVersionItem = new SDKVersion() { LatestAvailablePackage = latestPackage, Major = majorVersion, Minor = latestPackage.Version.Version.Minor }; // Check if we have one revision of the Major.Minor version already installed locally var localPackage = manager.LocalRepository.FindPackagesById(packageName).OrderByDescending(p => p.Version) .FirstOrDefault(p => p.Version.Version.Major == sdkVersionItem.Major && p.Version.Version.Minor == sdkVersionItem.Minor); sdkVersionItem.InstalledPackage = localPackage; Versions.Add(sdkVersionItem); } } // List of the startable versions RunnableVersions = Versions.Where(v => v.IsInstalled).ToList(); // VSIX plugin VsixVersion = new SDKVersion(); var vsixPackageList = serverVsixPackages; if (vsixPackageList.IsEmpty()) { vsixPackageList = localVsixPackages; } if (!vsixPackageList.IsEmpty()) { var latestVsix = vsixPackageList.FirstOrDefault(); VsixVersion.LatestAvailablePackage = latestVsix; // Check our VSIX currently installed VsixVersion.InstalledPackage = manager.LocalRepository.FindPackagesById(vsixPackageName).OrderByDescending(p => p.Version).FirstOrDefault(); } }