/// <summary>
        /// Determines of a package is the latest stable version.
        /// </summary>
        /// <param name="item">The package to verify.</param>
        /// <param name="latestStablePackage">If the package is the latest stable version, returns information about the package. Otherwise null.</param>
        /// <returns>Returns true if the package is the latest stable version. Otherwise false.</returns>
        public bool IsLatestStablePackage(CatalogItem item, out PackageInfo latestStablePackage)
        {
            // Try to get the latest version from the storage catalog
            latestStablePackage = this.GetLatestStablePackage(item.PackageId);

            // If the storage catalog didn't contain the package or the package is out-of-date, update
            // the latest stable version from the NuGet registration service.
            if (latestStablePackage == null || latestStablePackage.CommitTimeStamp <= item.CommitTimeStamp)
            {
                RegistrationIndexPackage latestStablePackageRegistration = item.GetLatestStableVersion(this.NugetServiceUrls);

                if (latestStablePackageRegistration == null)
                {
                    // If there isn't a latest stable version for this package, the input item can't be the latest stable version.
                    latestStablePackage = null;
                    return false;
                }
                else
                {
                    // Save the latest stable version.
                    latestStablePackage = this.SetLatestStablePackage(latestStablePackageRegistration.CatalogEntry.PackageId,
                        latestStablePackageRegistration.CatalogEntry.PackageVersion,
                        latestStablePackageRegistration.CommitId,
                        latestStablePackageRegistration.CommitTimeStamp,
                        latestStablePackageRegistration.PackageContent,
                        false);
                }
            }

            // Check if the item is the latest stable version.
            return latestStablePackage.LatestStableVersion.Equals(item.PackageVersion);
        }
        /// <summary>
        /// Sets the latest stable version of a package. If the package already exists in the PackageCatalog,
        /// it's metadata is updated with the provided values.
        /// </summary>
        /// <param name="packageId">The package id.</param>
        /// <param name="packageVersion">The package version.</param>
        /// <param name="commitId">The commit id.</param>
        /// <param name="commitTimeStamp">The commit timestamp.</param>
        /// <param name="downloadUrl">The download url for the package.</param>
        /// <param name="haveIdx">Indicates if we've created and stored the Idx for this package.</param>
        /// <returns>The package information for the input package.</returns>
        public PackageInfo SetLatestStablePackage(string packageId, string packageVersion, Guid commitId, DateTime commitTimeStamp, Uri downloadUrl, bool haveIdx)
        {
            PackageInfo packageInfo;

            lock (this._syncroot)
            {
                if (!this.Packages.TryGetValue(packageId, out packageInfo))
                {
                    packageInfo = new PackageInfo();
                    packageInfo.PackageId = packageId;
                }

                packageInfo.LatestStableVersion = packageVersion;
                packageInfo.CommitId = commitId;
                packageInfo.CommitTimeStamp = commitTimeStamp;
                packageInfo.DownloadUrl = downloadUrl;
                packageInfo.HaveIdx = haveIdx;

                this.Packages[packageInfo.PackageId] = packageInfo;
            }

            return packageInfo;
        }