Example #1
0
        private async Task <IEnumerable <string> > GenerateUrlsAsync(string bundleName, string fileExt)
        {
            var result       = new List <string>();
            var bundleExists = _bundleManager.Exists(bundleName);

            if (!bundleExists)
            {
                return(null);
            }

            if (_config.IsDebug)
            {
                var urls  = new List <string>();
                var files = _bundleManager.GetFiles(bundleName, _request);
                foreach (var d in files)
                {
                    urls.Add(d.FilePath);
                }

                foreach (var url in urls)
                {
                    result.Add(url);
                }
                return(result);
            }
            else
            {
                var compression = _request.GetClientCompression();
                var url         = _context.UrlCreator.GetUrl(bundleName, fileExt);

                //now we need to determine if these files have already been minified
                var compositeFilePath = _fileSystemHelper.GetCurrentCompositeFilePath(compression, bundleName);
                if (!File.Exists(compositeFilePath))
                {
                    var files = _bundleManager.GetFiles(bundleName, _request);
                    //we need to do the minify on the original files
                    foreach (var file in files)
                    {
                        await _fileManager.ProcessAndCacheFileAsync(file);
                    }
                }
                result.Add(url);
                return(result);
            }
        }