private IProject CreateProject(FullPathName rootPath) { var fileWithSections = new FileWithSections(rootPath.Combine(ConfigurationFilenames.ProjectFileNameDetection).FullName); var configurationProvider = new FileWithSectionConfigurationProvider(fileWithSections); return(new ProjectFileProject(configurationProvider, rootPath)); }
/// <summary> /// Create a project instance corresponding to the vschromium project file /// on disk at <paramref name="rootPath"/>. /// Return <code>null</code> if there is no project file. /// </summary> private Project CreateProject(FullPath rootPath) { var projectFilePath = rootPath.Combine(new RelativePath(ConfigurationFileNames.ProjectFileName)); var sectionName = ConfigurationSectionNames.SourceExplorerIgnore; if (!_fileSystem.FileExists(projectFilePath)) { projectFilePath = rootPath.Combine(new RelativePath(ConfigurationFileNames.ProjectFileNameObsolete)); sectionName = ConfigurationSectionNames.SourceExplorerIgnoreObsolete; if (!_fileSystem.FileExists(projectFilePath)) { return(null); } } var fileWithSections = new FileWithSections(_fileSystem, projectFilePath); var configurationProvider = new FileWithSectionConfigurationProvider(fileWithSections); var s1 = ConfigurationSectionContents.Create(configurationProvider, sectionName); var s2 = ConfigurationSectionContents.Create(configurationProvider, ConfigurationSectionNames.SearchableFilesIgnore); var s3 = ConfigurationSectionContents.Create(configurationProvider, ConfigurationSectionNames.SearchableFilesInclude); var fileFilter = new FileFilter(s1); var directoryFilter = new DirectoryFilter(s1); var searchableFilesFilter = new SearchableFilesFilter(s2, s3); return(new Project(rootPath, fileFilter, directoryFilter, searchableFilesFilter, fileWithSections.Hash)); }
/// <summary> /// Create a project instance corresponding to the vschromium project file /// on disk at <paramref name="rootPath"/>. /// Return <code>null</code> if there is no project file. /// </summary> private Project CreateProject(FullPath rootPath, FullPath searchPath) { var projectFilePath = rootPath.Combine(new RelativePath(ConfigurationFileNames.ProjectFileName)); var ignorePathsSectionName = ConfigurationSectionNames.SourceExplorerIgnore; if (!_fileSystem.FileExists(projectFilePath)) { projectFilePath = rootPath.Combine(new RelativePath(ConfigurationFileNames.ProjectFileNameObsolete)); ignorePathsSectionName = ConfigurationSectionNames.SourceExplorerIgnoreObsolete; if (!_fileSystem.FileExists(projectFilePath)) { return(null); } } var fileWithSections = new FileWithSections(_fileSystem, projectFilePath); var configurationProvider = new FileWithSectionConfigurationProvider(fileWithSections); var propertiesSection = ConfigurationSectionContents.Create(configurationProvider, ConfigurationSectionNames.Properties); var ignorePathsSection = ConfigurationSectionContents.Create(configurationProvider, ignorePathsSectionName); var ignoreSearchableFilesSection = ConfigurationSectionContents.Create(configurationProvider, ConfigurationSectionNames.SearchableFilesIgnore); var includeSearchableFilesSection = ConfigurationSectionContents.Create(configurationProvider, ConfigurationSectionNames.SearchableFilesInclude); var propertyCollection = new PropertyCollection(propertiesSection); var fileFilter = new FileFilter(ignorePathsSection); var directoryFilter = new DirectoryFilter(ignorePathsSection); var searchableFilesFilter = new SearchableFilesFilter(ignoreSearchableFilesSection, includeSearchableFilesSection); int rootDepth = 0; FullPath modifiedRootPath = rootPath; if (propertyCollection.TryGetInt("RootDepth", out rootDepth) && rootDepth > 0) { int rootPathDepth = rootPath.ToString().Split(Path.DirectorySeparatorChar).Count(); IEnumerable <string> pathComponents = searchPath.ToString().Split(Path.DirectorySeparatorChar); modifiedRootPath = new FullPath(string.Join(Path.DirectorySeparatorChar.ToString(), pathComponents.Take(rootPathDepth + rootDepth))); } return(new Project(modifiedRootPath, ignorePathsSection, ignoreSearchableFilesSection, includeSearchableFilesSection, fileFilter, directoryFilter, searchableFilesFilter, fileWithSections.Hash)); }