Ejemplo n.º 1
0
        private void AttachDynamicStyleSheets(HttpContextBase httpContext)
        {
            var paths = DynamicStyleSheetExtensions.GetRegisteredPaths(httpContext).ToArray();

            if (paths.Any())
            {
                const string headerName = "X-StyleSheets";

                var    bundle = DynamicBundleCreator.GerOrCreateStyleSheetBundleFor(paths);
                string urls   = Styles.RenderFormat("{0}", bundle.Path)
                                .ToHtmlString()
                                .Trim()
                                .Replace(Environment.NewLine, ",");
                httpContext.Response.Headers.Add(headerName, urls);
            }
        }
Ejemplo n.º 2
0
        public static IHtmlString RenderDynamicStyleSheets(this HtmlHelper helper)
        {
            if (helper == null)
            {
                throw new ArgumentNullException(nameof(helper));
            }

            var registeredPaths = GetRegisteredPaths(helper.ViewContext.HttpContext);

            if (!registeredPaths.Any())
            {
                return(MvcHtmlString.Empty);
            }

            var bundle = DynamicBundleCreator.GerOrCreateStyleSheetBundleFor(registeredPaths);

            return(Styles.Render(bundle.Path));
        }