public IEnumerable <ApplicationUninstallerEntry> GetUninstallerEntries(ListGenerationProgress.ListGenerationCallback progressCallback)
        {
            progressCallback(new ListGenerationProgress(0, -1, Localisation.Progress_DriveScan_Gathering));

            var existingUninstallers = _existingUninstallerEntries.ToList();

            var pfDirs     = UninstallToolsGlobalConfig.GetProgramFilesDirectories(true).ToList();
            var dirsToSkip = GetDirectoriesToSkip(existingUninstallers, pfDirs).ToList();

            var itemsToScan = GetDirectoriesToScan(existingUninstallers, pfDirs, dirsToSkip).ToList();

            var progress = 0;
            var results  = new List <ApplicationUninstallerEntry>();

            foreach (var directory in itemsToScan)
            {
                progressCallback(new ListGenerationProgress(progress++, itemsToScan.Count, directory.Key.FullName));

                if (UninstallToolsGlobalConfig.IsSystemDirectory(directory.Key) ||
                    directory.Key.Name.StartsWith("Windows", StringComparison.InvariantCultureIgnoreCase))
                {
                    continue;
                }

                var detectedEntries = TryCreateFromDirectory(directory.Key, directory.Value, dirsToSkip).ToList();

                results = ApplicationUninstallerFactory.MergeResults(results, detectedEntries, null);
            }

            return(results);
        }
예제 #2
0
        public static IEnumerable <ApplicationUninstallerEntry> DriveApplicationScan(
            ListGenerationProgress.ListGenerationCallback progressCallback,
            List <string> dirsToSkip,
            List <KeyValuePair <DirectoryInfo, bool?> > itemsToScan)
        {
            var dividedItems = SplitByPhysicalDrives(itemsToScan, pair => pair.Key);

            void GetUninstallerEntriesThread(KeyValuePair <DirectoryInfo, bool?> data, List <ApplicationUninstallerEntry> state)
            {
                if (UninstallToolsGlobalConfig.IsSystemDirectory(data.Key) ||
                    data.Key.Name.StartsWith("Windows", StringComparison.InvariantCultureIgnoreCase))
                {
                    return;
                }

                var detectedEntries = DirectoryFactory.TryCreateFromDirectory(data.Key, data.Value, dirsToSkip).ToList();

                ApplicationUninstallerFactory.MergeResults(state, detectedEntries, null);
            }

            var workSpreader = new ThreadedWorkSpreader <KeyValuePair <DirectoryInfo, bool?>, List <ApplicationUninstallerEntry> >
                                   (MaxThreadsPerDrive, GetUninstallerEntriesThread, list => new List <ApplicationUninstallerEntry>(list.Count), data => data.Key.FullName);

            workSpreader.Start(dividedItems, progressCallback);

            var results = new List <ApplicationUninstallerEntry>();

            foreach (var workerResults in workSpreader.Join())
            {
                ApplicationUninstallerFactory.MergeResults(results, workerResults, null);
            }

            return(results);
        }