示例#1
0
        public string Render(StylesheetBundle bundle)
        {
            var url          = urlGenerator.CreateBundleUrl(bundle);
            var html         = new StringBuilder();
            var hasCondition = !string.IsNullOrEmpty(bundle.Condition);

            if (hasCondition)
            {
                html.AppendLine("<!--[if " + bundle.Condition + "]>");
            }
            if (string.IsNullOrEmpty(bundle.Media))
            {
                html.AppendFormat(HtmlConstants.LinkHtml, url);
            }
            else
            {
                html.AppendFormat(HtmlConstants.LinkWithMediaHtml, url, bundle.Media);
            }
            if (hasCondition)
            {
                html.AppendLine();
                html.Append("<![endif]-->");
            }
            return(html.ToString());
        }
示例#2
0
        public string Render(StylesheetBundle bundle)
        {
            var url = urlGenerator.CreateBundleUrl(bundle);
            var conditionalRenderer = new ConditionalRenderer();

            return(conditionalRenderer.Render(bundle.Condition, html => RenderLink(bundle, html, url)));
        }
示例#3
0
 public string Render(ScriptBundle bundle)
 {
     return(string.Format(
                HtmlConstants.ScriptHtml,
                urlGenerator.CreateBundleUrl(bundle)
                ));
 }
        public string Render(StylesheetBundle bundle)
        {
            var url = urlGenerator.CreateBundleUrl(bundle);
            var conditionalRenderer = new ConditionalRenderer();

            return(conditionalRenderer.Render(bundle.Condition, html =>
            {
                if (string.IsNullOrEmpty(bundle.Media))
                {
                    html.AppendFormat(
                        HtmlConstants.LinkHtml,
                        url,
                        bundle.HtmlAttributes.CombinedAttributes
                        );
                }
                else
                {
                    html.AppendFormat(
                        HtmlConstants.LinkWithMediaHtml,
                        url,
                        bundle.Media,
                        bundle.HtmlAttributes.CombinedAttributes
                        );
                }
            }));
        }
 public string Render(HtmlTemplateBundle bundle)
 {
     return(string.Format(
                "<script src=\"{0}\" type=\"text/javascript\"></script>",
                urlGenerator.CreateBundleUrl(bundle)
                ));
 }
 public string Render(HtmlTemplateBundle bundle)
 {
     return(string.Format(
                "<script src=\"{0}\" type=\"text/javascript\"{1}></script>",
                urlGenerator.CreateBundleUrl(bundle),
                bundle.HtmlAttributes.CombinedAttributes
                ));
 }
示例#7
0
        public string CreateBundleUrl(Bundle bundle)
        {
            var theme = string.Empty;

            if (bundle.HtmlAttributes.ContainsAttribute("data-theme"))
            {
                theme = bundle.HtmlAttributes["data-theme"];
            }
            return(new Url(_inner.CreateBundleUrl(bundle)).AppendQuery("theme", theme));
        }
示例#8
0
 object HtmlTemplateData(HtmlTemplateBundle htmlTemplate, IUrlGenerator urlGenerator)
 {
     return(new
     {
         htmlTemplate.Path,
         Url = urlGenerator.CreateBundleUrl(htmlTemplate),
         Assets = AssetPaths(htmlTemplate, urlGenerator),
         htmlTemplate.References,
         Size = BundleSize(htmlTemplate)
     });
 }
示例#9
0
 public virtual IEnumerable <string> GetUrls(bool isDebuggingEnabled, IUrlGenerator urlGenerator)
 {
     if (isDebuggingEnabled)
     {
         var collector = new CollectLeafAssets();
         Accept(collector);
         return(collector.Assets.Select(urlGenerator.CreateAssetUrl));
     }
     else
     {
         return(new[] { urlGenerator.CreateBundleUrl(this) });
     }
 }
示例#10
0
        public string Render(ScriptBundle bundle)
        {
            var url     = urlGenerator.CreateBundleUrl(bundle);
            var content = string.Format(
                HtmlConstants.ScriptHtml,
                url,
                bundle.HtmlAttributes.CombinedAttributes
                );

            var conditionalRenderer = new ConditionalRenderer();

            return(conditionalRenderer.Render(bundle.Condition, html => html.Append(content)));
        }
示例#11
0
        object ScriptData(ScriptBundle script, IUrlGenerator urlGenerator)
        {
            var external = script as ExternalScriptBundle;

            return(new
            {
                script.Path,
                Url = external == null?urlGenerator.CreateBundleUrl(script) : external.Url,
                          Assets = AssetPaths(script, urlGenerator),
                          script.References,
                          Size = BundleSize(script)
            });
        }
示例#12
0
        public string Url <T>(string bundlePath)
            where T : Bundle
        {
            using (bundles.GetReadLock())
            {
                var bundle = bundles.FindBundlesContainingPath(bundlePath).OfType <T>().FirstOrDefault();
                if (bundle == null)
                {
                    throw new ArgumentException(string.Format("Bundle not found with path \"{0}\".", bundlePath));
                }

                return(urlGenerator.CreateBundleUrl(bundle));
            }
        }
示例#13
0
        object StylesheetData(StylesheetBundle stylesheet, IUrlGenerator urlGenerator)
        {
            var external = stylesheet as ExternalStylesheetBundle;

            return(new
            {
                stylesheet.Path,
                Url = external == null?urlGenerator.CreateBundleUrl(stylesheet) : external.Url,
                          stylesheet.Media,
                          stylesheet.Condition,
                          Assets = AssetPaths(stylesheet, urlGenerator),
                          stylesheet.References,
                          Size = BundleSize(stylesheet)
            });
        }
示例#14
0
 public IEnumerable <string> GetStylesheetUrls(string path)
 {
     using (bundles.GetReadLock())
     {
         var bundle = bundles.FindBundlesContainingPath(path).OfType <StylesheetBundle>().FirstOrDefault();
         if (bundle == null)
         {
             return(Enumerable.Empty <string>());
         }
         if (settings.IsDebuggingEnabled)
         {
             return(bundle.Assets.Select(urlGenerator.CreateAssetUrl));
         }
         else
         {
             return(new[] { urlGenerator.CreateBundleUrl(bundle) });
         }
     }
 }
示例#15
0
        public List<string> GetUrls(IUrlGenerator urlGenerator, bool isDebuggingEnabled)
        {
            string path = isDebuggingEnabled
                             ? urlGenerator.CreateAssetUrl(Asset)
                             : urlGenerator.CreateBundleUrl(Bundle) + "?";

            var urls = new List<string> { path };
            var externalBundle = Bundle as IExternalBundle;
            if (externalBundle != null)
            {
                var externalUrl = externalBundle.ExternalUrl;
                if (externalUrl.EndsWith(".js"))
                {
                    externalUrl = externalUrl.Substring(0, externalUrl.Length - 3);
                }
               urls.Insert(0,externalUrl);
            }
            return urls;
        }
示例#16
0
 public List<string> GetUrls(IUrlGenerator urlGenerator, bool isDebuggingEnabled)
 {
     return new List<string> { urlGenerator.CreateBundleUrl(this.Bundle)  + "?"};
 }
示例#17
0
 object StylesheetData(StylesheetBundle stylesheet, IUrlGenerator urlGenerator)
 {
     var external = stylesheet as ExternalStylesheetBundle;
     return new
     {
         stylesheet.Path,
         Url = external == null ? urlGenerator.CreateBundleUrl(stylesheet) : external.Url,
         stylesheet.Media,
         stylesheet.Condition,
         Assets = AssetPaths(stylesheet, urlGenerator),
         stylesheet.References,
         Size = BundleSize(stylesheet)
     };
 }
示例#18
0
 object ScriptData(ScriptBundle script, IUrlGenerator urlGenerator)
 {
     var external = script as ExternalScriptBundle;
     return new
     {
         script.Path,
         Url = external == null ? urlGenerator.CreateBundleUrl(script) : external.Url,
         Assets = AssetPaths(script, urlGenerator),
         script.References,
         Size = BundleSize(script)
     };
 }
示例#19
0
 object HtmlTemplateData(HtmlTemplateBundle htmlTemplate, IUrlGenerator urlGenerator)
 {
     return new
     {
         htmlTemplate.Path,
         Url = urlGenerator.CreateBundleUrl(htmlTemplate),
         Assets = AssetPaths(htmlTemplate, urlGenerator),
         htmlTemplate.References,
         Size = BundleSize(htmlTemplate)
     };
 }
示例#20
0
 internal virtual IEnumerable<string> GetUrls(bool isDebuggingEnabled, IUrlGenerator urlGenerator)
 {
     if (isDebuggingEnabled)
     {
         var collector = new CollectLeafAssets();
         Accept(collector);
         return collector.Assets.Select(urlGenerator.CreateAssetUrl);
     }
     else
     {
         return new[] { urlGenerator.CreateBundleUrl(this) };
     }
 }
 string CreateUrl(IAmdModule amdModule)
 {
     return(isDebuggingEnabled
         ? urlGenerator.CreateAssetUrl(amdModule.Asset)
         : urlGenerator.CreateBundleUrl(amdModule.Bundle) + "?");
 }