예제 #1
0
        public static PackageState Load(Config config)
        {
            RemotePackageConfig   remote = RemotePackageConfig.DownloadPackageConfig(config);
            InstalledPackageState local  = InstalledPackageState.Load();

            // Match local packages to remote ones
            List <LocalPackage> result =
                (from remotePackage in remote.Packages
                 join localPackage in local.Packages on remotePackage.Id equals localPackage.Id
                 select new LocalPackage(remotePackage, localPackage)).ToList();

            HashSet <string> matchedIds = new HashSet <string>(result.Select((p) => p.Local.Id));

            // Find remote packages that don't exist locally
            result.AddRange(remote.Packages
                            .Where((p) => !matchedIds.Contains(p.Id))
                            .Select((p) => new LocalPackage(p, null)));

            // (Don't care about local packages that don't exist remotely)

            return(new PackageState
            {
                LocalPackages = result,
            });
        }
예제 #2
0
        private void UpdateInstalledPackageState(List <RemotePackage> justInstalled)
        {
            var state = InstalledPackageState.Load();

            foreach (RemotePackage installed in justInstalled)
            {
                state.MarkInstalled(installed.ToInstalledPackage());
            }
            state.Save();
        }