Ejemplo n.º 1
0
        public IUpdateState DetermineUpdateState(IInstalledPackageMetadataCollection installedPackages, IPackageMetadataCollection remotePackages)
        {
            ISet <IPackageMetadata> outdatedPackages = new HashSet <IPackageMetadata>();

            foreach (IPackageMetadata packageMetadata in remotePackages.Values)
            {
                bool shouldUpdate = false;

                IInstalledPackageMetadata installedPackageMetadata = null;
                if (installedPackages.TryGetValue(packageMetadata.Id, out installedPackageMetadata))
                {
                    // Check if the installed version is outdated
                    if (installedPackageMetadata.PublishDate < packageMetadata.PublishDate)
                    {
                        // This package is outdated - update it!
                        shouldUpdate = true;
                    }
                }
                else
                {
                    // This package has not been installed
                    shouldUpdate = true;
                }

                if (shouldUpdate)
                {
                    outdatedPackages.Add(packageMetadata);
                }
            }

            return(new UpdateState(outdatedPackages));
        }
Ejemplo n.º 2
0
 private UpdaterCache(ICacheStorageProvider storageProvider, IInstalledPackageMetadataCollection installedMetadataCollection)
 {
     this.StorageProvider   = storageProvider;
     this.InstalledPackages = installedMetadataCollection;
 }