private bool HasParent(FileSystemInfoEx child, DirectoryInfoEx parent) { DirectoryInfoEx current = child.Parent; while (current != null) { if (current.Equals(parent)) { return(true); } current = current.Parent; } return(false); }
public DirectoryTreeItemViewModel LookupChild(DirectoryInfoEx directory, Func <bool> cancelCheck) { if (cancelCheck != null && cancelCheck()) { return(null); } if (Parent != null) { Parent.IsExpanded = true; } if (directory == null) { return(null); } if (!IsLoaded) { IsLoading = true; SubDirectories = getDirectories(); HasSubDirectories = SubDirectories.Count > 0; IsLoading = false; } foreach (DirectoryTreeItemViewModel subDirModel in SubDirectories) { if (!subDirModel.Equals(dummyNode)) { DirectoryInfoEx subDir = subDirModel.EmbeddedDirectoryModel.EmbeddedDirectoryEntry; if (directory.Equals(subDir)) { return(subDirModel); } else if (IOTools.HasParent(directory, subDir)) { return(subDirModel.LookupChild(directory, cancelCheck)); } } } return(null); }