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 List <ApplicationUninstallerEntry> MergeResults(ICollection <ApplicationUninstallerEntry> baseEntries, ICollection <ApplicationUninstallerEntry> newResults, InfoAdderManager infoAdder, 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(new ListGenerationProgress(progress++, newResults.Count, null)); var matchedEntries = baseEntries.Where(x => ApplicationEntryTools.AreEntriesRelated(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); }