private ICollection <object> GetChildItems(ProjectItems parentProjectItems) { var items = new ArrayList(); foreach (ProjectItem projectItem in GetProjectItems(parentProjectItems)) { if (ProjectItemExtensions.IsLinkedFile(projectItem)) { if (parentProjectItems.Parent is Project) { items.Add(CreateLinkedFileItem(projectItem, ((Project)parentProjectItems.Parent).FileName)); } else { items.Add(CreateLinkedFileItem(projectItem, ((ProjectItem)parentProjectItems.Parent).get_FileNames(0))); } } else { items.Add(CreateFileItem(projectItem)); items.AddRange((ICollection)GetChildItems(projectItem.ProjectItems)); } } foreach (ProjectItem projectItem in GetFolderItems(parentProjectItems)) { items.Add(CreateFolderItem(projectItem)); } return(items.ToArray()); }
private void CopyProjectItems(ProjectItems items, string destinationPath) { foreach (ProjectItem projectItem in items) { if (projectItem.IsAFile()) { if (ProjectItemExtensions.IsLinkedFile(projectItem)) { string parentPath; if (items.Parent is Project) { parentPath = Path.GetDirectoryName(((Project)items.Parent).FileName); } else { parentPath = Path.GetDirectoryName(((ProjectItem)items.Parent).get_FileNames(0)); } string path = PathUtil.RelativePathTo(parentPath, ProjectItemExtensions.Folder(projectItem)); string destinationFile = Path.Combine(destinationPath, path); if (!_fileSystem.Exists(destinationFile)) { _fileSystem.Copy(ProjectItemExtensions.Folder(projectItem), destinationFile); _fileTokenReplacer.Replace(destinationFile); } } else { for (short fileCount = 0; fileCount < projectItem.FileCount; fileCount++) { string file = projectItem.get_FileNames(fileCount); string destinationFile = Path.Combine(destinationPath, _fileSystem.GetFileNameWithExtension(file)); _fileSystem.Copy(file, destinationFile); _fileTokenReplacer.Replace(destinationFile); } CopyProjectItems(projectItem.ProjectItems, destinationPath); } } else { string folderPath = Path.Combine(destinationPath, projectItem.Name); CopyProjectItems(projectItem.ProjectItems, folderPath); } } }