private DocumentReader ParseInclude(string filePath) { Log.Info("Parsing included document at path '{0}'", filePath); using (new CompositeDisposable( new Log.ScopedIndent(), new Log.ScopedTimer(Log.Level.Debug, "Parse Include File", filePath))) { string configText = File.ReadAllText(filePath); IResult <ConfigDocument> result = DocumentParser.Document.TryParse(configText); if (!result.WasSuccessful) { throw new DocumentParseException(filePath, result.ToString()); } ConfigDocument configDoc = result.Value; var reader = new DocumentReader(configDoc, Solution.SolutionConfigDir); Log.Info("Finished parsing included document at path '{0}'", filePath); return(reader); } }
private List <ObjectElement> GetIncludedElements(string pathsPropertyName, Func <DocumentReader, IEnumerable <ObjectElement> > elementSelector) { using (new Log.ScopedIndent()) { IEnumerable <ObjectElement> modules = new List <ObjectElement>(); var includes = Solution.Settings.GetProperty <HashSet <IPattern> >(pathsPropertyName); HashSet <string> includePaths = FileUtil.GetFiles( Solution.FileCache, Path.GetRelativePath(Directory.GetCurrentDirectory(), Solution.SolutionConfigDir), includes, null); foreach (string includePath in includePaths) { DocumentReader reader = ParseInclude(includePath); reader.ParseElements(); modules = modules.Concat(elementSelector(reader)); } return(modules.ToList()); } }