/// <summary> /// Opens a text file, reads all lines of the file, and then closes the file /// </summary> /// <param name="path">The file to open for reading</param> /// <returns>The string containing all lines of the file</returns> public string ReadTextFile(string path) { if (path == null) { throw new ArgumentNullException("path", string.Format(CoreStrings.Common_ArgumentIsNull, "path")); } string content = _virtualFileSystemWrapper.GetFileTextContent(path); return(content); }
/// <summary> /// Gets a custom statistics from specified file /// </summary> /// <param name="path">Virtual path to file, that contains custom statistics</param> /// <returns>Custom statistics in JSON format</returns> private string GetCustomStatisticsFromFile(string path) { if (string.IsNullOrWhiteSpace(path)) { return(null); } if (!_virtualFileSystemWrapper.FileExists(path)) { throw new FileNotFoundException(string.Format(CoreStrings.Common_FileNotExist, path)); } string statistics = _virtualFileSystemWrapper.GetFileTextContent(path); return(statistics); }
/// <summary> /// Opens a file, reads all lines of the file, and then closes the file /// </summary> /// <param name="path">The file to open for reading</param> /// <returns>The string containing all lines of the file</returns> public string ReadFile(string path) { if (path == null) { throw new ArgumentNullException( nameof(path), string.Format(CoreStrings.Common_ArgumentIsNull, nameof(path)) ); } if (DefaultLibraryExists(path)) { return(ReadDefaultLibrary(path)); } string content = _virtualFileSystemWrapper.GetFileTextContent(path); return(content); }
/// <summary> /// Loads a JS externs dependencies from virtual file system /// </summary> /// <param name="externsFilePaths">List of JS externs file paths</param> /// <returns>List of JS externs dependencies</returns> private DependencyCollection LoadExternsDependenciesFromVirtualFileSystem(IList <string> externsFilePaths) { var externsDependencies = new DependencyCollection(); foreach (string externsFilePath in externsFilePaths) { if (_virtualFileSystemWrapper.FileExists(externsFilePath)) { string content = _virtualFileSystemWrapper.GetFileTextContent(externsFilePath); externsDependencies.Add(new Dependency(externsFilePath, content, true)); } else { throw new FileNotFoundException( string.Format(CoreStrings.Common_FileNotExist, externsFilePath)); } } return(externsDependencies); }