/// <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> /// 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 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> /// 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); }
/// <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); } } }