Exemplo n.º 1
0
 private static void BuildCss(CssPack pack)
 {
     const string cssTemplate = "<link rel=\"stylesheet\" type=\"text/css\" href=\"/{0}\" />";
     var fileList = pack.Files.ToList();
     var text = string.Join(string.Empty, fileList.Select(file => string.Format(cssTemplate, file)).ToArray());
     CssTagsInternal.Add(pack.Name, text);
 }
Exemplo n.º 2
0
 public static void AddCssPack(CssPack pack)
 {
     BuildCss(pack);
     if (!pack.SkipBundling)
     {
         BuildCompressedCss(pack);
     }
 }
Exemplo n.º 3
0
        private static void BuildCss(CssPack pack)
        {
            const string cssTemplate = "<link rel=\"stylesheet\" type=\"text/css\" href=\"/{0}\" />";
            var          fileList    = pack.Files.ToList();
            var          text        = string.Join(string.Empty, fileList.Select(file => string.Format(cssTemplate, file)).ToArray());

            CssTagsInternal.Add(pack.Name, text);
        }
Exemplo n.º 4
0
 public static void AddCssPack(CssPack pack)
 {
     BuildCss(pack);
     if (!pack.SkipBundling)
     {
         BuildCompressedCss(pack);
     }
 }
Exemplo n.º 5
0
        private static void BuildCompressedCss(CssPack pack)
        {
            var contents = Utils.GetCompressedContents(pack.Files, pack.BasePath, new StyleSheetCompressor());
            CompressedCssContentsInternal.Add(pack.Name, contents);

            if (string.IsNullOrWhiteSpace(pack.CacheBustingString))
            {
                pack.CacheBustingString = Utils.GetSignature(contents);
            }

            switch (pack.CacheBustingMethod)
            {
                case CacheBustingMethod.VaryByUrlPath:
                    var compressedTemplate = "<link rel=\"stylesheet\" type=\"text/css\" href=\"/bundles/css/{0}/{1}\" />";
                    CompressedCssTagsInternal.Add(pack.Name, string.Format(compressedTemplate, pack.CacheBustingString, pack.Name));
                    break;

                default:
                    compressedTemplate = "<link rel=\"stylesheet\" type=\"text/css\" href=\"/bundles/css/{0}?r={1}\" />";
                    CompressedCssTagsInternal.Add(pack.Name, string.Format(compressedTemplate, pack.Name, pack.CacheBustingString));
                    break;
            }
        }
Exemplo n.º 6
0
        private static void BuildCompressedCss(CssPack pack)
        {
            var contents = Utils.GetCompressedContents(pack.Files, pack.BasePath, new StyleSheetCompressor());

            CompressedCssContentsInternal.Add(pack.Name, contents);

            if (string.IsNullOrWhiteSpace(pack.CacheBustingString))
            {
                pack.CacheBustingString = Utils.GetSignature(contents);
            }

            switch (pack.CacheBustingMethod)
            {
            case CacheBustingMethod.VaryByUrlPath:
                var compressedTemplate = "<link rel=\"stylesheet\" type=\"text/css\" href=\"/bundles/css/{0}/{1}\" />";
                CompressedCssTagsInternal.Add(pack.Name, string.Format(compressedTemplate, pack.CacheBustingString, pack.Name));
                break;

            default:
                compressedTemplate = "<link rel=\"stylesheet\" type=\"text/css\" href=\"/bundles/css/{0}?r={1}\" />";
                CompressedCssTagsInternal.Add(pack.Name, string.Format(compressedTemplate, pack.Name, pack.CacheBustingString));
                break;
            }
        }