/// <summary>
        /// Merge duplicate junk entries and their confidence parts
        /// </summary>
        private static IEnumerable <IJunkResult> RemoveDuplicates(IEnumerable <IJunkResult> input)
        {
            foreach (var appGroup in input.GroupBy(x => x.Application))
            {
                foreach (var group in appGroup.GroupBy(x => PathTools.NormalizePath(x.GetDisplayName()).ToLowerInvariant()))
                {
                    IJunkResult firstJunkResult = null;
                    foreach (var junkResult in group)
                    {
                        if (firstJunkResult == null)
                        {
                            firstJunkResult = junkResult;
                        }
                        else
                        {
                            firstJunkResult.Confidence.AddRange(junkResult.Confidence.ConfidenceParts);
                        }
                    }

                    if (firstJunkResult != null)
                    {
                        yield return(firstJunkResult);
                    }
                }
            }
        }
Esempio n. 2
0
        private static bool JunkDoesNotPointToDirectories(IJunkResult arg, HashSet <string> prohibitedDirs)
        {
            if (arg is not FileSystemJunk fileSystemJunk)
            {
                return(true);
            }

            return(!prohibitedDirs.Contains(fileSystemJunk.Path.FullName.ToLowerInvariant()));
        }
 private static void OpenJunkNodePreview(IJunkResult item)
 {
     try
     {
         item.Open();
     }
     catch (Exception ex)
     {
         PremadeDialogs.GenericError(ex);
     }
 }
Esempio n. 4
0
        /// <summary>
        /// Make sure that the junk result doesn't point to this application.
        /// </summary>
        private static bool JunkDoesNotPointToSelf(IJunkResult x)
        {
            if (x is FileSystemJunk fileSystemJunk)
            {
                return(!fileSystemJunk.Path.FullName.StartsWith(UninstallToolsGlobalConfig.AppLocation, StringComparison.OrdinalIgnoreCase));
            }

            if (x is StartupJunkNode startupJunk)
            {
                return(!startupJunk.Entry.CommandFilePath.StartsWith(UninstallToolsGlobalConfig.AppLocation, StringComparison.OrdinalIgnoreCase));
            }

            return(true);
        }
        /// <summary>
        /// Make sure that the junk result doesn't point to this application.
        /// </summary>
        private static bool JunkDoesNotPointToSelf(IJunkResult x)
        {
            var fileSystemJunk = x as FileSystemJunk;

            if (fileSystemJunk != null)
            {
                return(!fileSystemJunk.Path.FullName.StartsWith(UninstallToolsGlobalConfig.AssemblyLocation, StringComparison.OrdinalIgnoreCase));
            }

            var startupJunk = x as StartupJunkNode;

            if (startupJunk != null)
            {
                return(!startupJunk.Entry.CommandFilePath.StartsWith(UninstallToolsGlobalConfig.AssemblyLocation, StringComparison.OrdinalIgnoreCase));
            }

            return(true);
        }
        private static void DisplayDetails(IJunkResult item)
        {
            var groups = item.Confidence.ConfidenceParts.GroupBy(part => part.Change > 0).ToList();

            var positives = Localisable.Empty;

            if (groups.Any(x => x.Key))
            {
                var items = groups.First(x => x.Key)
                            .Where(x => x.Reason.IsNotEmpty())
                            .Select(x => x.Reason)
                            .ToArray();
                if (items.Any())
                {
                    positives = string.Join("\n", items);
                }
            }

            var negatives = Localisable.Empty;

            if (groups.Any(x => !x.Key))
            {
                var items = groups.First(x => !x.Key)
                            .Where(x => x.Reason.IsNotEmpty())
                            .Select(x => x.Reason)
                            .ToArray();
                if (items.Any())
                {
                    negatives = string.Join("\n", items);
                }
            }

            MessageBox.Show(string.Format(CultureInfo.CurrentCulture, Localisable.JunkRemove_Details_Message,
                                          item.Confidence.GetRawConfidence(), positives, negatives), Localisable.JunkRemove_Details_Title,
                            MessageBoxButtons.OK, MessageBoxIcon.Information);
        }