private static void AddNonMemberFileItems(XProjectNode project, IList <string> fileList) { Utilities.ArgumentNotNull("fileList", fileList); foreach (string fileKey in fileList) { HierarchyNode parentNode = project; string[] pathItems = fileKey.Split(new char[] { Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar }); if (String.Equals(fileKey, project.ProjectFile, StringComparison.OrdinalIgnoreCase)) { continue; } XFolderNode topFolderNode = null; foreach (string fileOrDir in pathItems) { string childNodeId = Path.Combine(parentNode.VirtualNodeName, fileOrDir); FileInfo fileOrDirInfo = new FileInfo(Path.Combine(project.ProjectFolder, childNodeId)); if ((fileOrDirInfo.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden) { break; } //HierarchyNode childNode = project.FindURL(fileOrDirInfo.FullName); HierarchyNode childNode = parentNode.FindChild(childNodeId); if (childNode == null) { if (topFolderNode == null) { topFolderNode = parentNode as XFolderNode; if (topFolderNode != null && (!topFolderNode.IsNonMemberItem) && topFolderNode.IsExpanded) { topFolderNode = null; } } ProjectElement element = new ProjectElement(project, null, true); element.Rename(childNodeId); element.SetMetadata(ProjectFileConstants.Name, childNodeId); childNode = project.CreateFileNode(element); parentNode.AddChild(childNode); break; } parentNode = childNode; } if (topFolderNode != null) { topFolderNode.CollapseFolder(); } } }
private static void AddNonMemberFolderItems(XProjectNode project, IList <string> folderList) { if (folderList == null) { throw new ArgumentNullException("folderList"); } foreach (string folderKey in folderList) { HierarchyNode parentNode = project; string[] folders = folderKey.Split(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar); XFolderNode topFolderNode = null; foreach (string folder in folders) { string childNodeId = Path.Combine(parentNode.VirtualNodeName, folder); FileInfo folderInfo = new FileInfo(Path.Combine(project.ProjectFolder, childNodeId)); if ((folderInfo.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden) { break; } HierarchyNode childNode = parentNode.FindChild(childNodeId); if (childNode == null) { if (topFolderNode == null) { topFolderNode = parentNode as XFolderNode; if (topFolderNode != null && (!topFolderNode.IsNonMemberItem) && topFolderNode.IsExpanded) { topFolderNode = null; } } ProjectElement element = new ProjectElement(project, null, true); childNode = project.CreateFolderNode(childNodeId, element); parentNode.AddChild(childNode); } parentNode = childNode; } if (topFolderNode != null) { topFolderNode.CollapseFolder(); } } }