Ejemplo n.º 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());
        }
Ejemplo n.º 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)));
        }
Ejemplo n.º 3
0
 public string Render(ScriptBundle bundle)
 {
     return(string.Format(
                HtmlConstants.ScriptHtml,
                urlGenerator.CreateBundleUrl(bundle)
                ));
 }
Ejemplo n.º 4
0
        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
                ));
 }
Ejemplo n.º 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));
        }
Ejemplo n.º 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)
     });
 }
Ejemplo n.º 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) });
     }
 }
Ejemplo n.º 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)));
        }
Ejemplo n.º 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)
            });
        }
Ejemplo n.º 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));
            }
        }
Ejemplo n.º 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)
            });
        }
Ejemplo n.º 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) });
         }
     }
 }
Ejemplo n.º 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;
        }
Ejemplo n.º 16
0
 public List<string> GetUrls(IUrlGenerator urlGenerator, bool isDebuggingEnabled)
 {
     return new List<string> { urlGenerator.CreateBundleUrl(this.Bundle)  + "?"};
 }
Ejemplo n.º 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)
     };
 }
Ejemplo n.º 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)
     };
 }
Ejemplo n.º 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)
     };
 }
Ejemplo n.º 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) };
     }
 }
Ejemplo n.º 21
0
 string CreateUrl(IAmdModule amdModule)
 {
     return(isDebuggingEnabled
         ? urlGenerator.CreateAssetUrl(amdModule.Asset)
         : urlGenerator.CreateBundleUrl(amdModule.Bundle) + "?");
 }