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;
}
ThreadHelper.ThrowIfNotOnUIThread();
if (topFolderNode != null)
{
topFolderNode.CollapseFolder();
}
}
}