private static List <ApplicationUninstallerEntry> MergeResults(ICollection <ApplicationUninstallerEntry> baseEntries,
                                                                       ICollection <ApplicationUninstallerEntry> newResults, InfoAdderManager infoAdder, ListGenerationProgress.ListGenerationCallback progressCallback)
        {
            // Create local copy
            //var baseEntries = baseResults.ToList();
            // Add all of the base results straight away
            var results  = new List <ApplicationUninstallerEntry>(baseEntries);
            var progress = 0;

            foreach (var entry in newResults)
            {
                progressCallback(new ListGenerationProgress(progress++, newResults.Count, null));

                var matchedEntries = baseEntries.Where(x => CheckAreEntriesRelated(x, entry)).Take(2).ToList();
                if (matchedEntries.Count == 1)
                {
                    // Prevent setting incorrect UninstallerType
                    if (matchedEntries[0].UninstallPossible)
                    {
                        entry.UninstallerKind = UninstallerType.Unknown;
                    }

                    infoAdder.CopyMissingInformation(matchedEntries[0], entry);
                    continue;
                }

                // If the entry failed to match to anything, add it to the results
                results.Add(entry);
            }

            return(results);
        }
        internal static List <ApplicationUninstallerEntry> MergeResults(ICollection <ApplicationUninstallerEntry> baseEntries,
                                                                        ICollection <ApplicationUninstallerEntry> newResults, ListGenerationProgress.ListGenerationCallback progressCallback)
        {
            // Add all of the base results straight away
            var results  = new List <ApplicationUninstallerEntry>(baseEntries);
            var progress = 0;

            foreach (var entry in newResults)
            {
                progressCallback?.Invoke(new ListGenerationProgress(progress++, newResults.Count, null));

                var matchedEntry = baseEntries.Select(x => new { x, score = ApplicationEntryTools.AreEntriesRelated(x, entry) })
                                   .Where(x => x.score >= 1)
                                   .OrderByDescending(x => x.score)
                                   .Select(x => x.x)
                                   .FirstOrDefault();

                if (matchedEntry != null)
                {
                    // Prevent setting incorrect UninstallerType
                    if (matchedEntry.UninstallPossible)
                    {
                        entry.UninstallerKind = UninstallerType.Unknown;
                    }

                    InfoAdder.CopyMissingInformation(matchedEntry, entry);
                    continue;
                }

                // If the entry failed to match to anything, add it to the results
                results.Add(entry);
            }

            return(results);
        }
 private static void ApplyCache(List <ApplicationUninstallerEntry> baseEntries, ApplicationUninstallerFactoryCache cache, InfoAdderManager infoAdder)
 {
     foreach (var entry in baseEntries)
     {
         var matchedEntry = cache.TryGetCachedItem(entry);
         if (matchedEntry != null)
         {
             infoAdder.CopyMissingInformation(entry, matchedEntry);
         }
     }
 }
Beispiel #4
0
        private static void ApplyCache(ICollection <ApplicationUninstallerEntry> baseEntries, ApplicationUninstallerFactoryCache cache, InfoAdderManager infoAdder)
        {
            var hits = 0;

            foreach (var entry in baseEntries)
            {
                var matchedEntry = cache.TryGetCachedItem(entry);
                if (matchedEntry != null)
                {
                    infoAdder.CopyMissingInformation(entry, matchedEntry);
                    hits++;
                }
                else
                {
                    Debug.WriteLine("Cache miss: " + entry.DisplayName);
                }
            }
            Console.WriteLine($@"Cache hits: {hits}/{baseEntries.Count}");
        }