/// <summary> /// Add the files to the project /// </summary> /// <param name="absPaths">List of absolute paths to files to add to the project</param> /// <param name="folder">Folder that should contain the files in the project</param> public void AddFiles(IEnumerable<string> absPaths, SledProjectFilesFolderType folder) { foreach (var absPath in absPaths.Where(File.Exists)) { SledProjectFilesFileType file; m_projectService.AddFile(absPath, folder, out file); } }
private static void GatherFiles(SledProjectFilesFolderType rootFolder, ref List <SledProjectFilesFileType> lstFiles) { // Add files from this folder lstFiles.AddRange(rootFolder.Files); // Search sub-folders foreach (var folder in rootFolder.Folders) { GatherFiles(folder, ref lstFiles); } }
/// <summary> /// Add folder to project /// </summary> /// <param name="name">Name of the folder</param> /// <param name="parent">Folder to add the new folder to</param> /// <param name="folder">Handle to folder in project</param> /// <returns>True if folder added or false if not</returns> public bool AddFolder(string name, SledProjectFilesFolderType parent, out SledProjectFilesFolderType folder) { folder = null; if (string.IsNullOrEmpty(name)) return false; if (!Active) return false; var domNode = new DomNode(SledSchema.SledProjectFilesFolderType.Type); folder = domNode.As<SledProjectFilesFolderType>(); folder.Name = name; if (parent == null) ActiveProject.Folders.Add(folder); else parent.Folders.Add(folder); return true; }
/// <summary> /// Add folder to project /// </summary> /// <param name="name">Name of the folder</param> /// <param name="folder">Handle to folder in project</param> /// <returns>True if folder added or false if not</returns> public bool AddFolder(string name, out SledProjectFilesFolderType folder) { return AddFolder(name, null, out folder); }
/// <summary> /// Add file to project with specified folder /// </summary> /// <param name="absPath">Absolute path to file</param> /// <param name="folder">Folder to add the file to</param> /// <param name="file">Handle to file in project</param> /// <returns>True if file added (or already in the project) or false if not</returns> public bool AddFile(string absPath, SledProjectFilesFolderType folder, out SledProjectFilesFileType file) { file = m_projectFileFinderService.Get.Find(absPath); if (file != null) return true; var project = ActiveProject; // Create new project file (if possible) bool bAlreadyInProject; file = m_projectFilesUtilityService.Get.CreateFrom(absPath, project, out bAlreadyInProject); if (file == null) return false; if (bAlreadyInProject) return true; // Add to project (DOM will handle firing the event) if (folder == null) project.Files.Add(file); else folder.Files.Add(file); return true; }
/// <summary> /// Constructor /// </summary> /// <param name="project">Project</param> /// <param name="folder">Folder</param> /// <param name="oldName">Old name (used when folder name is changed)</param> /// <param name="newName">New name (used when folder name is changed)</param> public SledProjectServiceFolderEventArgs(SledProjectFilesType project, SledProjectFilesFolderType folder, string oldName, string newName) : base(project) { Folder = folder; OldName = oldName; NewName = newName; }
/// <summary> /// Constructor /// </summary> /// <param name="project">Project</param> /// <param name="folder">Folder</param> public SledProjectServiceFolderEventArgs(SledProjectFilesType project, SledProjectFilesFolderType folder) : this(project, folder, string.Empty, string.Empty) { }
/// <summary> /// Add the files to the project /// </summary> /// <param name="uris">List of uris to add to the project</param> /// <param name="folder">Folder that should contain the files in the project</param> public void AddFiles(IEnumerable<Uri> uris, SledProjectFilesFolderType folder) { AddFiles(uris.Select(u => u.AbsolutePath), folder); }
private static void AddTree(ISledProjectService projectService, SledProjectFilesFolderType folder, Tree<FileSystemInfo> tree, IEnumerable<string> extensions) { if ((projectService == null) || (tree == null)) return; var parent = folder; if (tree.Value.IsDirectory()) projectService.AddFolder(tree.Value.Name, folder, out parent); foreach (var item in tree.Children) { if (item.Value.IsDirectory()) AddTree(projectService, parent, item, extensions); else { var theItem = item; var shouldAdd = extensions == null ? true : extensions.Any(ext => string.Compare(ext, theItem.Value.Extension, StringComparison.OrdinalIgnoreCase) == 0); if (!shouldAdd) continue; SledProjectFilesFileType projFile; projectService.AddFile(item.Value.FullName, parent, out projFile); } } }
/// <summary> /// Add the files from the specified tree to the project /// </summary> /// <param name="tree">Tree representing disk structure to add to the project</param> /// <param name="extensions">Extensions from the tree to add to the project (null adds all files)</param> /// <param name="folder">Folder that should contain the files after adding (null adds to root)</param> public void AddFilesFromTree(Tree<FileSystemInfo> tree, IEnumerable<string> extensions, SledProjectFilesFolderType folder) { if (tree == null) return; AddTree(m_projectService, folder, tree, extensions); }
/// <summary> /// Add the files from the specified folders to the project /// </summary> /// <param name="absFolderPaths">Folders to search in</param> /// <param name="searchOption">Whether to recursively search or not</param> /// <param name="extensions">File extensions to grab</param> /// <param name="folder">Folder that should contain the files</param> public void AddFilesInFolders(IEnumerable<string> absFolderPaths, SearchOption searchOption, IEnumerable<string> extensions, SledProjectFilesFolderType folder) { foreach (var absFolderPath in absFolderPaths) { try { var dir = new DirectoryInfo(absFolderPath); if (!dir.Exists) continue; Func<FileInfo, bool> filePredicate = fi => { if (m_isHidden(fi)) return false; return extensions == null || extensions.Any(ext => string.Compare(ext, fi.Extension, StringComparison.OrdinalIgnoreCase) == 0); }; var tree = dir.GetFilesAndDirectoriesTree(searchOption, filePredicate, m_dirPredicate); AddTree(m_projectService, folder, tree, null); } catch (Exception ex) { SledOutDevice.OutLine( SledMessageType.Error, "{0}: Exception finding files in directory {1}: {2}", this, absFolderPaths, ex.Message); } } }