PowerShellUtils/Commands/PrintTree/ClearLeavesFailingFilterImpl.cs
using System;
using System.Collections.Generic; using System.IO; using System.Linq; namespace PowerShellStandardModule1.Commands.PrintTree; public class ClearLeavesFailingFilterImpl(Func<FileSystemInfo, bool> filter) { public void Invoke(IList<FileSystemInfoTreeNode> result) { foreach (var treeNode in result) { treeNode.Children = treeNode .Children.Where(x => x.Children.Count > 0 || filter(x.Value)) .ToList(); } } } |