Пример #1
0
        /// <summary>
        /// Gets a bundle file by virtual path
        /// </summary>
        /// <param name="bundle">Bundle</param>
        /// <param name="virtualPath">Virtual path</param>
        /// <returns>Bundle</returns>
        protected virtual BundleFile GetBundleFileByVirtualPath(Bundle bundle, string virtualPath)
        {
            BundleFile file = null;
            string     url  = _virtualFileSystemWrapper.ToAbsolutePath(virtualPath);

            url = UrlHelpers.ProcessBackSlashes(url);
            url = RemoveAdditionalFileExtension(url);

            var bundleContext = new BundleContext(_context, BundleTable.Bundles, bundle.Path);
            IEnumerable <BundleFile> bundleFiles = bundle.EnumerateFiles(bundleContext);

            foreach (BundleFile bundleFile in bundleFiles)
            {
                string bundleFileUrl = _virtualFileSystemWrapper.ToAbsolutePath(bundleFile.VirtualFile.VirtualPath);
                bundleFileUrl = UrlHelpers.ProcessBackSlashes(bundleFileUrl);
                bundleFileUrl = RemoveAdditionalFileExtension(bundleFileUrl);

                if (string.Equals(bundleFileUrl, url, StringComparison.OrdinalIgnoreCase))
                {
                    file = bundleFile;
                    break;
                }
            }

            return(file);
        }
        /// <summary>
        /// Gets a list of included files
        /// </summary>
        /// <param name="path">Virtual path to file, that contains custom statistics</param>
        /// <returns>List of included files</returns>
        private IList <string> GetIncludedFilePaths(string path)
        {
            var includedFilePaths = new List <string>();

            if (!string.IsNullOrWhiteSpace(path))
            {
                includedFilePaths.Add(_virtualFileSystemWrapper.ToAbsolutePath(path));
            }

            return(includedFilePaths);
        }
Пример #3
0
        /// <summary>
        /// Converts a relative path to an application absolute path
        /// </summary>
        /// <param name="path">The relative path</param>
        /// <returns>The absolute path representation of the specified relative path</returns>
        public string ToAbsolutePath(string path)
        {
            if (path == null)
            {
                throw new ArgumentNullException("path",
                                                string.Format(CoreStrings.Common_ArgumentIsNull, "path"));
            }

            if (!_appRelativePathRegex.IsMatch(path))
            {
                return(path);
            }

            string absolutePath = _virtualFileSystemWrapper.ToAbsolutePath(path);

            return(absolutePath);
        }
Пример #4
0
        /// <summary>
        /// Converts a relative path to an absolute path.
        /// A return value indicates whether the conversion succeeded.
        /// </summary>
        /// <param name="relativePath">The relative path</param>
        /// <param name="absolutePath">The absolute path</param>
        /// <returns>true if path was converted successfully; otherwise, false</returns>
        private bool TryConvertToAbsolutePath(string relativePath, out string absolutePath)
        {
            absolutePath = null;

            if (relativePath.StartsWith("/") || UrlHelpers.StartsWithProtocol(relativePath))
            {
                absolutePath = relativePath;
                return(true);
            }

            if (relativePath.StartsWith("~/"))
            {
                absolutePath = _virtualFileSystemWrapper.ToAbsolutePath(relativePath);
                return(true);
            }

            return(false);
        }
        /// <summary>
        /// Converts a relative path to an application absolute path
        /// </summary>
        /// <param name="path">The relative path</param>
        /// <returns>The absolute path representation of the specified relative path</returns>
        public string ToAbsolutePath(string path)
        {
            if (path == null)
            {
                throw new ArgumentNullException(
                          nameof(path),
                          string.Format(CoreStrings.Common_ArgumentIsNull, nameof(path))
                          );
            }

            if (!IsAppRelativePath(path))
            {
                return(path);
            }

            string absolutePath = _virtualFileSystemWrapper.ToAbsolutePath(path);

            return(absolutePath);
        }
        /// <summary>
        /// Gets a list of common JS externs dependencies
        /// </summary>
        /// <returns>List of common JS externs dependencies</returns>
        protected DependencyCollection GetCommonExternsDependencies()
        {
            IList <string> commonExternsFilePaths = CommonExternsFilePaths;

            if (CompilationLevel != CompilationLevel.Advanced || commonExternsFilePaths.Count == 0)
            {
                return(new DependencyCollection());
            }

            IList <string> processedCommonExternsFilePaths = commonExternsFilePaths
                                                             .Select(f => _virtualFileSystemWrapper.ToAbsolutePath(f))
                                                             .Distinct(StringComparer.OrdinalIgnoreCase)
                                                             .ToList()
            ;

            DependencyCollection commonExternsDependencies = LoadExternsDependenciesFromVirtualFileSystem(
                processedCommonExternsFilePaths);

            return(commonExternsDependencies);
        }
Пример #7
0
        public string GetCurrentDirectory()
        {
            string currentDirectoryName = _virtualFileSystemWrapper.ToAbsolutePath("~/");

            return(currentDirectoryName);
        }