コード例 #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
ファイル: Updater.cs プロジェクト: mcoot/TribesLauncherSharp
        private void UpdateInstalledPackageState(List <RemotePackage> justInstalled)
        {
            var state = InstalledPackageState.Load();

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