private void ParseFile()
 {
     try
     {
         this.FileContents = FileReader.ReadFileAsString(this.Path);
     }
     catch (Exception e)
     {
         this.ErrorMessage = e.Message;
         return;
     }
     if (this.FileContents != null)
     {
         this.RootPowershellItem = PowershellTokenizer.GetPowershellItems(this.Path, this.FileContents);
         this.ErrorMessage       = this.RootPowershellItem.ParsingErrors;
     }
 }
Exemplo n.º 2
0
        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));
        }