protected void PopulatePropertyTree(DirectoryProperty root) { try { int index = root.ChildIndex; if (!Property.IsValidIndex(index)) { return; } Stack <Property> children = new Stack <Property>(); children.Push(_properties[index]); while (children.Count != 0) { Property property = children.Pop(); if (property == null) { // unknown / unsupported / corrupted property, skip continue; } root.AddChild(property); if (property.IsDirectory) { PopulatePropertyTree((DirectoryProperty)property); } index = property.PreviousChildIndex; if (Property.IsValidIndex(index)) { children.Push(_properties[index]); } index = property.NextChildIndex; if (Property.IsValidIndex(index)) { children.Push(_properties[index]); } } } catch (IOException ex) { throw ex; } }
private void PopulatePropertyTree(DirectoryProperty root) { int index = root.ChildIndex; if (!Property.IsValidIndex(index)) { // property has no children return; } Stack children = new Stack(); children.Push(_properties[index]); while (!(children.Count == 0)) { Property property = ( Property )children.Pop(); if (property == null) { continue; } root.AddChild(property); if (property.IsDirectory) { PopulatePropertyTree(( DirectoryProperty )property); } index = property.PreviousChildIndex; if (Property.IsValidIndex(index)) { children.Push(_properties[index]); } index = property.NextChildIndex; if (Property.IsValidIndex(index)) { children.Push(_properties[index]); } } }