Ejemplo n.º 1
0
        protected string ProcessAppendHash(Uri cssRootPathUri, string fileContents)
        {
            if (_localCssAssetFilesThatExist == null)
            {
                _localCssAssetFilesThatExist = new List <FileInfo>();
            }

            var distinctLocalPaths          = CssPathRewriter.FindDistinctLocalPaths(fileContents);
            var distinctLocalPathsThatExist = new List <Uri>();

            foreach (var distinctLocalPath in distinctLocalPaths)
            {
                var cssAssetFileInfo = new FileInfo(PathProvider.MapPath(cssRootPathUri, distinctLocalPath));

                if (!cssAssetFileInfo.Exists)
                {
                    continue;
                }

                distinctLocalPathsThatExist.Add(distinctLocalPath);
                _localCssAssetFilesThatExist.Add(cssAssetFileInfo);
            }

            return(CssPathRewriter.RewriteCssPathsToAppendHash(distinctLocalPathsThatExist, cssRootPathUri, fileContents));
        }
Ejemplo n.º 2
0
        private IEnumerable <CssAsset> GetCssAssets(Uri cssAbsoluteUriDirectory, string fileContents)
        {
            var distinctLocalPaths = _cssPathRewriter.FindDistinctLocalPaths(fileContents);

            return(distinctLocalPaths
                   .Select(distinctLocalPath => new CssAsset
            {
                File = new FileInfo(new Uri(_pathProvider.MapPath(cssAbsoluteUriDirectory, distinctLocalPath)).LocalPath),
                Url = distinctLocalPath
            })
                   .Where(cssAssetFileInfo => cssAssetFileInfo.File.Exists));
        }