Closed ChrisClems closed 3 weeks ago
Re-opening to assess need for TraverseAssemblyWithAction and TraverseOccurrencesWithAction. I suspect both are functionally identical with the former being more expensive. The former traverses the assembly by casting an Occurrence to a SolidEdgeDocument then to an AssemblyDocument when found. The latter walks the SubOccurrences of the Occurrences and SubOccurrences when they are SubAssemblies, getting Occurrences from SucOccurrences using SubOccurrences.ThisAsOccurrence to perform actions on.
When using SubOccurrence.ThisAsOccurrence you change the top-level assembly context in the same way that casting the SubAssembly Occurrence to an AssemblyDocument does. Performing the Action on the SolidEdgeDocument instead of the Occurrence is limiting as we can get the SolidEdgeDocument from the Occurrence but not the other way around. Is there any value in maintaining the (likely) more expensive original version when we can just traverse the SubOccurrences much faster?
Replaced original method with a full occurrence tree walk from the top level without casting subassemblies to assemblies. Can revisit if edge case comes up where that works better.
https://github.com/ironfede/openmcdf/blob/a61b6b9a836865781c2588b9b6bf711f30137e17/sources/OpenMcdf/CFStorage.cs#L493
Add as Assembly extension method?