Ejemplo n.º 1
0
        private static string PrepareText(string text)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append(text);

            if (ExtNetTransformer.RenderStyles != ResourceLocationType.None)
            {
                ExtNetTransformer.ShareIcons(sb);
                ExtNetTransformer.ShareStyles(sb);
            }

            if (ExtNetTransformer.RenderScripts != ResourceLocationType.None)
            {
                ExtNetTransformer.ShareScripts(sb);
            }

            ExtNetTransformer.ShareBeforeAfterScripts(sb);

            if (HttpContext.Current.Items.Contains(Ext.Net.ResourceManager.GLOBAL_RESOURCES))
            {
                HttpContext.Current.Items.Remove(Ext.Net.ResourceManager.GLOBAL_RESOURCES);
            }

            return(sb.ToString());
        }
Ejemplo n.º 2
0
        private static void ShareStyles(StringBuilder sb, MVC.MvcResourceManagerConfig config)
        {
            if (HttpContext.Current.Items["Ext.Net.GlobaResources"] != null)
            {
                List <ResourceItem> styles = (List <ResourceItem>)HttpContext.Current.Items["Ext.Net.GlobalResources"];

                foreach (var item in styles)
                {
                    if (item is ClientStyleItem)
                    {
                        var styleItem = (ClientStyleItem)item;

                        switch (config.RenderStyles)
                        {
                        case ResourceLocationType.File:
                            sb.AppendFormat(ResourceManager.StyleIncludeTemplate, config.ResourcePath.ConcatWith(styleItem.Path));
                            break;

                        default:
                        case ResourceLocationType.Embedded:
                            sb.AppendFormat(ResourceManager.StyleIncludeTemplate, ExtNetTransformer.GetWebResourceUrl(styleItem.Type, styleItem.PathEmbedded, config));
                            break;
                        }
                    }
                }
            }
        }
Ejemplo n.º 3
0
        private static string PrepareText(string text)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append(text);

            var config = MVC.MvcResourceManager.SharedConfig;

            if (config.RenderStyles != ResourceLocationType.None)
            {
                ExtNetTransformer.ShareIcons(sb);
                ExtNetTransformer.ShareStyles(sb, config);
            }

            if (config.RenderScripts != ResourceLocationType.None)
            {
                ExtNetTransformer.ShareScripts(sb, config);
            }

            if (HttpContext.Current.Items.Contains("Ext.Net.GlobaResources"))
            {
                HttpContext.Current.Items.Remove("Ext.Net.GlobaResources");
            }

            return(sb.ToString());
        }
Ejemplo n.º 4
0
        /// <summary>
        ///
        /// </summary>
        protected virtual void Transform()
        {
            string h = ExtNetTransformer.Transform(this.html.ToString());

            this.html.Remove(0, this.html.Length);
            this.html.Append(h);
        }
        /// <summary>
        ///
        /// </summary>
        protected virtual void Transform()
        {
            //var start = DateTime.Now.Ticks;
            string h = ExtNetTransformer.Transform(this.html.ToString());

            this.html.Remove(0, this.html.Length);
            this.html.Append(h);
            //var end = DateTime.Now.Ticks;
            //string ticksMsg = string.Format("ticks({0});",TimeSpan.FromTicks(end - start).TotalMilliseconds);
            //this.html.Replace("Ext.onReady(function(){", "Ext.onReady(function(){"+ticksMsg);
        }
Ejemplo n.º 6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="type"></param>
        /// <param name="resourceName"></param>
        /// <param name="config"></param>
        /// <returns></returns>
        public static string GetWebResourceUrl(Type type, string resourceName)
        {
            if (resourceName.StartsWith(ResourceManager.ASSEMBLYSLUG) && ExtNetTransformer.CleanResourceUrl && ResourceHandler.HasHandler())
            {
                string buster = (resourceName.EndsWith(".js") || resourceName.EndsWith(".css")) ? "?v=".ConcatWith(ResourceManager.CacheBuster) : "";

                string url = "~{0}/ext.axd{1}".FormatWith(resourceName.Replace(ResourceManager.ASSEMBLYSLUG, "").Replace('.', '/').ReplaceLastInstanceOf("/", "-"), buster);

                return(ExtNetTransformer.ResolveUrl(url));
            }

            return(HttpUtility.HtmlAttributeEncode(CachedPageInstance.ClientScript.GetWebResourceUrl(type, resourceName)));
        }
Ejemplo n.º 7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="text"></param>
        /// <returns></returns>
        new public static string Transform(string text)
        {
            try
            {
                return(new ExtNetTransformer(ExtNetTransformer.PrepareText(text)).Transform());
            }
            catch (System.Exception e)
            {
                if (e.Message.Contains("Reference token (init_script) was not found"))
                {
                    throw new Exception("Probably ResourceManager is not defined in the View");
                }

                throw;
            }
        }
Ejemplo n.º 8
0
        public virtual string BuildHtml()
        {
            string html = "<div class=\"start-loading-mask mask-el{0}\"{1}></div><div class=\"start-loading mask-el{2}\"{3}><div class=\"loading-indicator{4}\"{5}><img {6}{7} src=\"{10}\" align=\"middle\" /><p{8}{9}>{11}</p></div></div>";

            return(string.Format(html,
                                 this.LoadingMaskCls.IsNotEmpty() ? " " + this.LoadingMaskCls : "",
                                 this.LoadingMaskStyle.IsNotEmpty() ? " style=\"" + this.LoadingMaskStyle + "\"" : "",
                                 this.LoadingContainerCls.IsNotEmpty() ? " " + this.LoadingContainerCls : "",
                                 this.LoadingContainerStyle.IsNotEmpty() ? " style=\"" + this.LoadingContainerStyle + "\"" : "",
                                 this.LoadingIndicatorCls.IsNotEmpty() ? " " + this.LoadingIndicatorCls : "",
                                 this.LoadingIndicatorStyle.IsNotEmpty() ? " style=\"" + this.LoadingIndicatorStyle + "\"" : "",
                                 this.ImageCls.IsNotEmpty() ? " class=\"" + this.ImageCls + "\"" : "",
                                 this.ImageStyle.IsNotEmpty() ? " style=\"" + this.ImageStyle + "\"" : "",
                                 this.MessageCls.IsNotEmpty() ? " class=\"" + this.MessageCls + "\"" : "",
                                 this.MessageStyle.IsNotEmpty() ? " style=\"" + this.MessageStyle + "\"" : "",
                                 this.ImageUrl.IsNotEmpty() ? ExtNetTransformer.ResolveUrl(this.ImageUrl) : ExtNetTransformer.GetWebResourceUrl(typeof(ResourceManager), "Ext.Net.Build.Ext.Net.extnet.resources.images.start-loading.gif"),
                                 this.Message
                                 ));
        }
Ejemplo n.º 9
0
        private static void CheckResources(BaseControl control, InsertOrderedDictionary <string, string> scripts, InsertOrderedDictionary <string, string> styles)
        {
            foreach (ClientScriptItem item in control.GetScripts())
            {
                string resourcePath = GlobalConfig.Settings.ScriptMode == ScriptMode.Debug && item.PathEmbeddedDebug.IsNotEmpty() ? item.PathEmbeddedDebug : item.PathEmbedded;

                if (!scripts.ContainsKey(resourcePath))
                {
                    scripts.Add(resourcePath, ExtNetTransformer.GetWebResourceUrl(item.Type, resourcePath));
                }
            }

            foreach (ClientStyleItem item in control.GetStyles())
            {
                if (!styles.ContainsKey(item.PathEmbedded) && item.Theme.Equals(Theme.Default))
                {
                    styles.Add(item.PathEmbedded, ExtNetTransformer.GetWebResourceUrl(item.Type, item.PathEmbedded));
                }
            }
        }
Ejemplo n.º 10
0
        private static void ShareStyles(StringBuilder sb, MVC.MvcResourceManagerConfig config)
        {
            if (HttpContext.Current.Items[Ext.Net.ResourceManager.GLOBAL_RESOURCES] != null)
            {
                var placeholder = HttpContext.Current.Items["Ext.Net.InitStyle"] != null;
                sb.AppendFormat("<#:item {0}='{1}' index='11'>", placeholder ? "ref" : "selector", placeholder ? "ext.net.initstyle" : "headstart");

                List <ResourceItem> styles = (List <ResourceItem>)HttpContext.Current.Items[Ext.Net.ResourceManager.GLOBAL_RESOURCES];

                foreach (var item in styles)
                {
                    if (item is ClientStyleItem)
                    {
                        var styleItem = (ClientStyleItem)item;

                        switch (config.RenderStyles)
                        {
                        case ResourceLocationType.File:
                            sb.AppendFormat(ResourceManager.StyleIncludeTemplate, config.ResourcePath.ConcatWith(styleItem.Path));
                            break;

#if ISPRO
                        case ResourceLocationType.CDN:
                            sb.AppendFormat(ResourceManager.StyleIncludeTemplate, ResourceManager.CDNPath.ConcatWith(styleItem.Path));
                            break;
#endif
                        default:
                        case ResourceLocationType.Embedded:
                            sb.AppendFormat(ResourceManager.StyleIncludeTemplate, ExtNetTransformer.GetWebResourceUrl(styleItem.Type, styleItem.PathEmbedded, config));
                            break;
                        }
                    }
                }

                sb.Append("</#:item>");
            }
        }
Ejemplo n.º 11
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="text"></param>
 /// <param name="config"></param>
 /// <returns></returns>
 new public static string Transform(string text, TextTransformerConfig config)
 {
     return(new ExtNetTransformer(ExtNetTransformer.PrepareText(text), config).Transform());
 }
Ejemplo n.º 12
0
        private static void ShareScripts(StringBuilder sb)
        {
            if (HttpContext.Current.Items[Ext.Net.ResourceManager.GLOBAL_RESOURCES] != null)
            {
                bool placeholder = HttpContext.Current.Items["Ext.Net.InitScriptFiles"] != null;

                sb.AppendFormat("<#:item {0}='{1}' index='21'>", placeholder ? "ref" : "selector", placeholder ? "ext.net.initscriptfiles" : "headstart");

                List <ResourceItem> scripts = (List <ResourceItem>)HttpContext.Current.Items[Ext.Net.ResourceManager.GLOBAL_RESOURCES];

                foreach (ResourceItem item in scripts)
                {
                    if (item is ClientScriptItem)
                    {
                        ClientScriptItem scriptItem = (ClientScriptItem)item;

                        if (scriptItem.IgnoreResourceMode)
                        {
                            if (scriptItem.PathEmbedded.IsNotEmpty())
                            {
                                sb.AppendFormat(ResourceManager.ScriptIncludeTemplate, (ExtNetTransformer.ScriptMode == ScriptMode.Release || scriptItem.PathEmbeddedDebug.IsEmpty()) ? scriptItem.PathEmbedded : scriptItem.PathEmbeddedDebug);
                            }
                            else
                            {
                                bool isDebug = !(ExtNetTransformer.ScriptMode == ScriptMode.Release || scriptItem.PathEmbeddedDebug.IsEmpty());
                                sb.AppendFormat(ResourceManager.ScriptIncludeTemplate, (isDebug ? scriptItem.PathDebug : scriptItem.Path).StartsWith("~") ? ExtNetTransformer.ResolveUrl(isDebug ? scriptItem.PathDebug : scriptItem.Path) : (isDebug ? scriptItem.PathDebug : scriptItem.Path));
                            }

                            continue;
                        }

                        if (ExtNetTransformer.RenderScripts == ResourceLocationType.Embedded)
                        {
                            if (ExtNetTransformer.ScriptMode == ScriptMode.Release || scriptItem.PathEmbeddedDebug.IsEmpty())
                            {
                                sb.AppendFormat(ResourceManager.ScriptIncludeTemplate, ExtNetTransformer.GetWebResourceUrl(scriptItem.Type, scriptItem.PathEmbedded));
                            }
                            else
                            {
                                sb.AppendFormat(ResourceManager.ScriptIncludeTemplate, ExtNetTransformer.GetWebResourceUrl(scriptItem.Type, scriptItem.PathEmbeddedDebug));
                            }
                        }
                        else if (ExtNetTransformer.RenderScripts == ResourceLocationType.File)
                        {
                            if (ExtNetTransformer.ScriptMode == ScriptMode.Release || scriptItem.PathDebug.IsEmpty())
                            {
                                sb.AppendFormat(ResourceManager.ScriptIncludeTemplate, scriptItem.Path.StartsWith("~") ? ExtNetTransformer.ResolveUrl(scriptItem.Path) : ExtNetTransformer.ResourcePath.ConcatWith(scriptItem.Path));
                            }
                            else
                            {
                                sb.AppendFormat(ResourceManager.ScriptIncludeTemplate, scriptItem.PathDebug.StartsWith("~") ? ExtNetTransformer.ResolveUrl(scriptItem.PathDebug) : ExtNetTransformer.ResourcePath.ConcatWith(scriptItem.PathDebug));
                            }
                        }
#if ISPRO
                        else if (ExtNetTransformer.RenderScripts == ResourceLocationType.CDN)
                        {
                            if (ExtNetTransformer.ScriptMode == ScriptMode.Release || scriptItem.PathDebug.IsEmpty())
                            {
                                sb.AppendFormat(ResourceManager.ScriptIncludeTemplate, ResourceManager.CDNPath.ConcatWith(scriptItem.Path));
                            }
                            else
                            {
                                sb.AppendFormat(ResourceManager.ScriptIncludeTemplate, ResourceManager.CDNPath.ConcatWith(scriptItem.PathDebug));
                            }
                        }
#endif
                    }
                }

                List <ClientResourceItem> gbScripts = (List <ClientResourceItem>)HttpContext.Current.Items[ResourceManager.GLOBAL_CLIENT_RESOURCES];

                if (gbScripts != null)
                {
                    foreach (ClientResourceItem item in gbScripts)
                    {
                        if (!item.IsCss)
                        {
                            if (item.Path.IsNotEmpty())
                            {
                                sb.AppendFormat(ResourceManager.ScriptIncludeTemplate, item.Path.StartsWith("~") ? ExtNetTransformer.ResolveUrl(item.Path) : item.Path);
                            }
                            else if (item.PathEmbedded.IsNotEmpty())
                            {
                                sb.AppendFormat(ResourceManager.ScriptIncludeTemplate, HttpUtility.HtmlAttributeEncode(CachedPageInstance.ClientScript.GetWebResourceUrl(item.Type, item.PathEmbedded)));
                            }
                        }
                    }
                }

                sb.Append("</#:item>");
            }
        }
Ejemplo n.º 13
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="text"></param>
 /// <returns></returns>
 new public static string Transform(string text)
 {
     return(new ExtNetTransformer(ExtNetTransformer.PrepareText(text)).Transform());
 }
Ejemplo n.º 14
0
        private static void ShareStyles(StringBuilder sb)
        {
            if (HttpContext.Current.Items[Ext.Net.ResourceManager.GLOBAL_RESOURCES] != null)
            {
                bool placeholder = HttpContext.Current.Items["Ext.Net.InitStyle"] != null;

                sb.AppendFormat("<#:item {0}='{1}' index='11'>", placeholder ? "ref" : "selector", placeholder ? "ext.net.initstyle" : "headstart");

                List <ResourceItem> styles = (List <ResourceItem>)HttpContext.Current.Items[Ext.Net.ResourceManager.GLOBAL_RESOURCES];

                foreach (ResourceItem item in styles)
                {
                    if (item is ClientStyleItem)
                    {
                        if (item.IgnoreResourceMode)
                        {
                            if (item.PathEmbedded.IsNotEmpty())
                            {
                                sb.AppendFormat(ResourceManager.StyleIncludeTemplate, ExtNetTransformer.GetWebResourceUrl(item.Type, item.PathEmbedded));
                            }
                            else
                            {
                                sb.AppendFormat(ResourceManager.StyleIncludeTemplate, item.Path.StartsWith("~") ? ExtNetTransformer.ResolveUrl(item.Path) : item.Path);
                            }
                            continue;
                        }

                        ClientStyleItem styleItem = (ClientStyleItem)item;

                        switch (ExtNetTransformer.RenderStyles)
                        {
                        case ResourceLocationType.File:
                            sb.AppendFormat(ResourceManager.StyleIncludeTemplate, styleItem.Path.StartsWith("~") ? ExtNetTransformer.ResolveUrl(styleItem.Path) : ExtNetTransformer.ResourcePath.ConcatWith(styleItem.Path));
                            break;

#if ISPRO
                        case ResourceLocationType.CDN:
                            sb.AppendFormat(ResourceManager.StyleIncludeTemplate, ResourceManager.CDNPath.ConcatWith(styleItem.Path));
                            break;
#endif
                        default:
                        case ResourceLocationType.Embedded:
                            sb.AppendFormat(ResourceManager.StyleIncludeTemplate, ExtNetTransformer.GetWebResourceUrl(styleItem.Type, styleItem.PathEmbedded));
                            break;
                        }
                    }
                }

                List <ClientResourceItem> gbStyles = (List <ClientResourceItem>)HttpContext.Current.Items[ResourceManager.GLOBAL_CLIENT_RESOURCES];

                if (gbStyles != null)
                {
                    foreach (ClientResourceItem item in gbStyles)
                    {
                        if (item.IsCss)
                        {
                            if (item.Path.IsNotEmpty())
                            {
                                sb.AppendFormat(ResourceManager.StyleIncludeTemplate, item.Path.StartsWith("~") ? ExtNetTransformer.ResolveUrl(item.Path) : item.Path);
                            }
                            else if (item.PathEmbedded.IsNotEmpty())
                            {
                                sb.AppendFormat(ResourceManager.StyleIncludeTemplate, HttpUtility.HtmlAttributeEncode(CachedPageInstance.ClientScript.GetWebResourceUrl(item.Type, item.PathEmbedded)));
                            }
                        }
                    }
                }

                sb.Append("</#:item>");
            }
        }
Ejemplo n.º 15
0
        private static void ShareScripts(StringBuilder sb, MVC.MvcResourceManagerConfig config)
        {
            if (HttpContext.Current.Items["Ext.Net.GlobaResources"] != null)
            {
                List <ResourceItem> scripts = (List <ResourceItem>)HttpContext.Current.Items["Ext.Net.GlobalResources"];

                foreach (var item in scripts)
                {
                    if (item is ClientScriptItem)
                    {
                        var scriptItem = (ClientScriptItem)item;

                        if (config.RenderScripts == ResourceLocationType.Embedded)
                        {
                            if (config.ScriptMode == ScriptMode.Release || scriptItem.PathEmbeddedDebug.IsEmpty())
                            {
                                sb.AppendFormat(ResourceManager.ScriptIncludeTemplate, ExtNetTransformer.GetWebResourceUrl(scriptItem.Type, scriptItem.PathEmbedded, config));
                            }
                            else
                            {
                                sb.AppendFormat(ResourceManager.ScriptIncludeTemplate, ExtNetTransformer.GetWebResourceUrl(scriptItem.Type, scriptItem.PathEmbeddedDebug, config));
                            }
                        }
                        else if (config.RenderScripts == ResourceLocationType.File)
                        {
                            if (config.ScriptMode == ScriptMode.Release || scriptItem.PathDebug.IsEmpty())
                            {
                                sb.AppendFormat(ResourceManager.ScriptIncludeTemplate, config.ResourcePath.ConcatWith(scriptItem.Path));
                            }
                            else
                            {
                                sb.AppendFormat(ResourceManager.ScriptIncludeTemplate, config.ResourcePath.ConcatWith(scriptItem.PathDebug));
                            }
                        }
                        else if (config.RenderScripts == ResourceLocationType.CDN)
                        {
                            if (config.ScriptMode == ScriptMode.Release || scriptItem.PathDebug.IsEmpty())
                            {
                                sb.AppendFormat(ResourceManager.ScriptIncludeTemplate, ResourceManager.CDNPath.ConcatWith(scriptItem.Path));
                            }
                            else
                            {
                                sb.AppendFormat(ResourceManager.ScriptIncludeTemplate, ResourceManager.CDNPath.ConcatWith(scriptItem.PathDebug));
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 16
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="text"></param>
 /// <param name="tokensType"></param>
 /// <param name="variables"></param>
 /// <returns></returns>
 new public static string Transform(string text, List <Type> tokensType, Dictionary <string, string> variables)
 {
     return(new ExtNetTransformer(ExtNetTransformer.PrepareText(text)).Transform(tokensType, variables));
 }
Ejemplo n.º 17
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="text"></param>
 /// <param name="variables"></param>
 /// <returns></returns>
 new public static string Transform(string text, Dictionary <string, string> variables)
 {
     return(new ExtNetTransformer(ExtNetTransformer.PrepareText(text)).Transform(variables));
 }
Ejemplo n.º 18
0
        private static void ShareScripts(StringBuilder sb, MVC.MvcResourceManagerConfig config)
        {
            if (HttpContext.Current.Items[Ext.Net.ResourceManager.GLOBAL_RESOURCES] != null)
            {
                var placeholder = HttpContext.Current.Items["Ext.Net.InitScriptFiles"] != null;
                sb.AppendFormat("<#:item {0}='{1}' index='21'>", placeholder ? "ref" : "selector", placeholder ? "ext.net.initscriptfiles" : "headstart");

                List <ResourceItem> scripts = (List <ResourceItem>)HttpContext.Current.Items[Ext.Net.ResourceManager.GLOBAL_RESOURCES];

                foreach (var item in scripts)
                {
                    if (item is ClientScriptItem)
                    {
                        var scriptItem = (ClientScriptItem)item;

                        if (config.RenderScripts == ResourceLocationType.Embedded)
                        {
                            if (config.ScriptMode == ScriptMode.Release || scriptItem.PathEmbeddedDebug.IsEmpty())
                            {
                                sb.AppendFormat(ResourceManager.ScriptIncludeTemplate, ExtNetTransformer.GetWebResourceUrl(scriptItem.Type, scriptItem.PathEmbedded, config));
                            }
                            else
                            {
                                sb.AppendFormat(ResourceManager.ScriptIncludeTemplate, ExtNetTransformer.GetWebResourceUrl(scriptItem.Type, scriptItem.PathEmbeddedDebug, config));
                            }
                        }
                        else if (config.RenderScripts == ResourceLocationType.File)
                        {
                            if (config.ScriptMode == ScriptMode.Release || scriptItem.PathDebug.IsEmpty())
                            {
                                sb.AppendFormat(ResourceManager.ScriptIncludeTemplate, config.ResourcePath.ConcatWith(scriptItem.Path));
                            }
                            else
                            {
                                sb.AppendFormat(ResourceManager.ScriptIncludeTemplate, config.ResourcePath.ConcatWith(scriptItem.PathDebug));
                            }
                        }
#if ISPRO
                        else if (config.RenderScripts == ResourceLocationType.CDN)
                        {
                            if (config.ScriptMode == ScriptMode.Release || scriptItem.PathDebug.IsEmpty())
                            {
                                sb.AppendFormat(ResourceManager.ScriptIncludeTemplate, ResourceManager.CDNPath.ConcatWith(scriptItem.Path));
                            }
                            else
                            {
                                sb.AppendFormat(ResourceManager.ScriptIncludeTemplate, ResourceManager.CDNPath.ConcatWith(scriptItem.PathDebug));
                            }
                        }
#endif
                    }
                }

                sb.Append("</#:item>");
            }
        }
Ejemplo n.º 19
0
        public static void Redirect(string url, string msg, string msgCls)
        {
            if (url.IsEmpty())
            {
                throw new ArgumentNullException("url", "The redirection url is empty");
            }

            if (msg.IsNotEmpty())
            {
                X.Mask.Show(new MaskConfig
                {
                    Msg    = msg,
                    MsgCls = msgCls
                });
            }

            Ext.Net.ResourceManager.AddInstanceScript("window.location=\"".ConcatWith(TokenUtils.IsRawToken(url) ? url : ExtNetTransformer.ResolveUrl(url), "\";"));
        }
Ejemplo n.º 20
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="text"></param>
 /// <param name="tokensType"></param>
 /// <returns></returns>
 new public static string Transform(string text, List <Type> tokensType)
 {
     return(new ExtNetTransformer(ExtNetTransformer.PrepareText(text)).Transform(tokensType));
 }