Esempio n. 1
0
        private static List <App> GetDifference(List <App> apps)
        {
            var result = new List <App>();

            if (!File.Exists(_config.CacheFileName))
            {
                return(apps);
            }
            var cachedApps = AppsContainer.FromBytes(File.ReadAllBytes(_config.CacheFileName)).apps;

            foreach (var app in apps)
            {
                var cachedApp = cachedApps.Find(a => a.name == app.name);
                if (cachedApp != null)
                {
                    cachedApps.Remove(cachedApp);
                    if (app.version == cachedApp.version)
                    {
                        continue;
                    }
                    app.status = AppStatus.Updated;
                }
                result.Add(app);
            }

            cachedApps.ForEach(app => app.status = AppStatus.Deleted);
            result.AddRange(cachedApps);
            return(result);
        }