public IFileInclusionHierarchy Combine(IFileInclusionHierarchy hierarchy, FileInclusionPolicy secondPolicy) { if (hierarchy == null) throw new ArgumentNullException("hierarchy"); if (secondPolicy == null) throw new ArgumentNullException("secondPolicy"); var newPolicy = new FileInclusionPolicy(); AddFrom(hierarchy.Policy, newPolicy); AddFrom(secondPolicy, newPolicy); return new FileInclusionHierarchy(wildcardMatcher, newPolicy); }
void AddIncludedFiles(CodeDirectory currentDirectory, IFileInclusionHierarchy fileInclusionHierarchy, Project currentProject) { if (currentProject == null) return; foreach (var file in currentDirectory.Files.Where(x => fileInclusionHierarchy.ShouldInclude(x.FilePath))) { currentProject.AddFile(new ProjectFile { FullPath = file.FilePath, RelativePath = relativePathGenerator.GeneratePath(currentProject.Path, file.FilePath) }); } }
void AddFiles(Solution solution, CodeDirectory currentDirectory, IFileInclusionHierarchy fileInclusionHierarchy = null, Project currentProject = null) { fileInclusionHierarchy = UpdateFileInclusionPolicy(currentDirectory, fileInclusionHierarchy); if (currentDirectory.Project != null) { currentProject = solution.GetProject(currentDirectory.Project.AssemblyName); } AddIncludedFiles(currentDirectory, fileInclusionHierarchy, currentProject); currentDirectory.Directories.Each(x => AddFiles(solution, x, fileInclusionHierarchy, currentProject)); }
IFileInclusionHierarchy UpdateFileInclusionPolicy(CodeDirectory currentDirectory, IFileInclusionHierarchy fileInclusionHierarchy) { if (fileInclusionHierarchy == null) { fileInclusionHierarchy = fileInclusionHierarchyBuilder.Create(currentDirectory.FileInclusionPolicy ?? new FileInclusionPolicy()); } else if (currentDirectory.FileInclusionPolicy != null) { fileInclusionHierarchy = fileInclusionHierarchyBuilder.Combine(fileInclusionHierarchy, currentDirectory.FileInclusionPolicy); } return fileInclusionHierarchy; }