//------------------------------------------------------------------ //private methods private string FormSingleMinifiedFileInclude(string bundleName, CssOrJs cssOrJs, FileTypeConfigInfo fileTypeInfo, Func<string, string> getContentUrl) { var relFilePath = $"~/{fileTypeInfo.Directory}{bundleName}.min.{cssOrJs.ToString().ToLowerInvariant()}"; var fileUrl = getContentUrl(relFilePath); var htmlLink = fileTypeInfo.NonDebugHtmlFormatString.Replace(FileTypeConfigInfo.FileUrlParam, fileUrl); if (fileTypeInfo.NonDebugHtmlFormatString.Contains(FileTypeConfigInfo.CachebusterParam)) { var cacheBusterValue = _getChecksumFromRelPath(relFilePath); htmlLink = htmlLink.Replace(FileTypeConfigInfo.CachebusterParam, cacheBusterValue); } return htmlLink; }
private string FormCdnIncludes(IEnumerable<CdnInfo> cdnLinks, string bundleName, CssOrJs cssOrJs, FileTypeConfigInfo fileTypeInfo, Func<string, string> getContentUrl) { if (string.IsNullOrEmpty(fileTypeInfo.CdnHtmlFormatString)) throw new InvalidOperationException( $"The bundle {bundleName} contains a cdn definition, but the current config does not support CDN for {cssOrJs}"); var sb = new StringBuilder(); //we send the individual files as found in the bundle json file foreach (var cdnLink in cdnLinks) { var relFilePath = $"~/{fileTypeInfo.Directory}{cdnLink.Production}"; var httpFileUrl = getContentUrl(relFilePath); sb.AppendLine(cdnLink.BuildCdnIncludeString(fileTypeInfo.CdnHtmlFormatString, httpFileUrl, () => _getChecksumFromRelPath(relFilePath))); } return sb.ToString(); }