Пример #1
0
        /// <summary>
        /// Render All Scripts for the Stratum registered so far on the page.
        /// </summary>
        /// <param name="helper"></param>
        /// <returns>Script include</returns>
        public static IHtmlString StrataScripts()
        {
            List <string> loaded = new List <string>();

            string[] allScripts = new string[0];
            string   pageKey    = "stratum:" + HttpContext.Current.Request.Path;

            //var page = helper.ViewDataContainer as WebPageExecutingBase;
            string virtualPath = HttpContext.Current.Request.Path;

            if (!String.IsNullOrWhiteSpace(virtualPath) && virtualPath.StartsWith("~/"))
            {
                virtualPath = virtualPath.Substring(1);
            }
            if (HttpContext.Current.Application[pageKey] != null)
            {
                loaded = HttpContext.Current.Application[pageKey] as List <string>;
                foreach (string componentName in loaded)
                {
                    UiStratum component = new UiStratum(componentName, "", "", null, null);
                    //virtualPath = ConstructScriptBundle(helper, virtualPath, component.ListBundleScripts());
                    allScripts = allScripts.Concat(component.ListBundleScripts()).ToArray();
                }
            }
            return(RenderBundle <ScriptBundle>(virtualPath, allScripts) as HtmlString);
        }
Пример #2
0
        /// <summary>
        /// Renders a specific set of scripts as a bundle for one specific component
        /// </summary>
        /// <param name="componentName"></param>
        /// <param name="bundleName"></param>
        /// <returns></returns>
        public static IHtmlString StratumScripts(string componentName, string rootPath = "", string myId = "", object modelData = null, string bundleName = null)
        {
            UiStratum     component = new UiStratum(componentName, rootPath, myId, modelData, new UiStratumTypes.BackboneMustache());
            StringBuilder scripts   = new StringBuilder();

            scripts.Append(RenderBundle <ScriptBundle>(bundleName, component.ListBundleScripts()).ToString());
            scripts.Append(component.RenderBackboneViewModel());
            return(new HtmlString(scripts.ToString()));
        }