public PowershellFileParser(string path, bool isDirectory, string errorMessage) { this.Path = path; this.IsDirectory = isDirectory; this.ErrorMessage = errorMessage; if (!this.IsDirectory && FilesPatternProvider.IsPowershellFile(path)) { this.ParseFile(); } else { this.FileContents = string.Empty; } }
public PowershellParseResult ParseFile(string path, bool isDirectory, bool isExcluded, string errorMessage) { if (isExcluded || isDirectory || !FilesPatternProvider.IsPowershellFile(path)) { return(new PowershellParseResult(null, errorMessage, path, null, isDirectory, isExcluded)); } string fileContents; try { fileContents = fileReader.ReadFileAsString(path); } catch (Exception e) { return(new PowershellParseResult(null, e.Message, path, null, isDirectory, isExcluded)); } if (fileContents != null) { var rootPowershellItem = this.powershellTokenizer.GetPowershellItems(path, fileContents); return(new PowershellParseResult(rootPowershellItem, errorMessage, path, fileContents, isDirectory, isExcluded)); } return(new PowershellParseResult(null, errorMessage, path, fileContents, isDirectory, isExcluded)); }