Пример #1
0
        /// <summary>
        /// Render and register a Stratum UI component in the page
        /// </summary>
        /// <param name="helper"></param>
        /// <param name="componentName">name of the component (should correlate the folder in /Components/)</param>
        /// <param name="data"></param>
        /// <param name="withScripts"></param>
        /// <returns></returns>
        public static IHtmlString Stratum <T>(string componentName, string rootPath = "", string myId = "", object data = null, bool withScripts = false, bool withStyles = true, bool withTemplates = true, bool withViewInit = false) where T : UiStratumType
        {
            UiStratumType newType   = (T)Activator.CreateInstance(typeof(T));
            UiStratum     component = new UiStratum(componentName, rootPath, myId, data, newType);
            List <string> loaded    = new List <string>();
            string        pageKey   = "stratum:" + HttpContext.Current.Request.Path;

            if (HttpContext.Current.Application[pageKey] != null)
            {
                loaded = HttpContext.Current.Application[pageKey] as List <string>;
            }
            loaded.Add(componentName);
            HttpContext.Current.Application[pageKey] = loaded;
            string output = "";

            if (withStyles)
            {
                output += component.RenderStyles();
            }
            output += component.RenderComponentHtml(withTemplates, withScripts, withViewInit);
            return(new HtmlString(output));
        }
Пример #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 StratumStyles(string componentName, string rootPath = "", string bundleName = null)
        {
            UiStratum component = new UiStratum(componentName, rootPath, "", null, new UiStratumTypes.BackboneMustache());

            return(new HtmlString(component.RenderStyles()));
        }