ironfede / openmcdf

Microsoft Compound File .net component - pure C# - netstandard 2.0
Mozilla Public License 2.0
297 stars 73 forks source link

Add `IEnumerable<CFItem> EnumerateChildren()` to CFStorage #72

Closed tstenner closed 1 year ago

tstenner commented 3 years ago

This PR adds an EnumerateChildren() method and rewrites VisitEntries() to use it in the background.

This allows both enumerate via foreach as well as LINQ as wished for in #58.

Examples, adapted from the unit tests:

// total number of storages
stg.EnumerateChildren(true).Where(e => e.IsStorage).Count();
stg.EnumerateChildren(false).Where(e => e.Name.Contains("Stream")).Count();
foreach(var item in stg.EnumerateChildren(false))
                if (item.Name == "MyStream") System.Console.Out.WriteLine(item.Name);