示例#1
0
 public static string NormalizeRawToken(string script)
 {
     if (TokenUtils.IsRawToken(script))
     {
         return(TokenUtils.ReplaceRawToken(script));
     }
     return(string.Concat("\"", script, "\""));
 }
示例#2
0
 public static string ReplaceRawToken(string script)
 {
     if (TokenUtils.IsRawToken(script))
     {
         script = (script.StartsWith("<raw>")) ? script.Substring(5) : script.Substring(0, script.Length - 1).Substring(2);
     }
     return(script);
 }
示例#3
0
        protected string ParseTarget(string target)
        {
            string parsedTarget = TokenUtils.ParseTokens(target, this);

            if (TokenUtils.IsRawToken(parsedTarget))
            {
                return(TokenUtils.ReplaceRawToken(parsedTarget));
            }

            return(string.Concat("\"", parsedTarget, "\""));
        }
示例#4
0
 public virtual void Filter(string field, string value, bool anyMatch, bool caseSensitive)
 {
     if (TokenUtils.IsRawToken(value))
     {
         value = TokenUtils.ReplaceRawToken(value);
     }
     else
     {
         value = JSON.Serialize(value);
     }
     this.AddScript("{0}.filter({1},{2},{3},{4});", this.ClientID, JSON.Serialize(field), value, JSON.Serialize(anyMatch), JSON.Serialize(caseSensitive));
 }
示例#5
0
        public string ToString(bool camelNames)
        {
            ParameterMode mode = this.Mode;
            string        name = camelNames ? StringUtils.ToLowerCamelCase(this.Name) : this.Name;

            if (this.Params.Count > 0)
            {
                return(this.ToStringInnerParams(name));
            }
            else
            {
                string script = TokenUtils.ParseTokens(this.Value, this.Owner);
                if (TokenUtils.IsRawToken(script))
                {
                    mode   = ParameterMode.Raw;
                    script = TokenUtils.ReplaceRawToken(script);
                }
                return(string.Concat(JSON.Serialize(name), ":", this.Encode ? "Ext.encode(" : "", mode == ParameterMode.Raw ? script : JSON.Serialize(script), this.Encode ? ")" : ""));
            }
        }
示例#6
0
        public static string ParseTokens(string script, Control seed)
        {
            if (seed == null)
            {
                seed = TokenUtils.Page;
            }

            bool isRaw = (
                TokenUtils.IsAlertToken(script) ||
                TokenUtils.IsRawToken(script) ||
                TokenUtils.IsSelectToken(script));

            script = TokenUtils.ReplaceIDTokens(script, seed);
            script = TokenUtils.ReplaceSelectTokens(script);

            script = TokenUtils.ReplaceAlertToken(script);
            script = TokenUtils.ReplaceRawToken(script);
            script = TokenUtils.ReplaceFunctionToken(script);

            return((isRaw || TokenUtils.IsFunction(script)) ? string.Concat("<raw>", script) : script);
        }
示例#7
0
        public string ValueToString()
        {
            ParameterMode mode = this.Mode;

            if (this.Params.Count > 0)
            {
                return(this.ToStringInnerParams(null));
            }
            else
            {
                string script = TokenUtils.ParseTokens(this.Value, this.Owner);

                if (TokenUtils.IsRawToken(script))
                {
                    mode   = ParameterMode.Raw;
                    script = TokenUtils.ReplaceRawToken(script);
                }

                return(string.Concat(this.Encode ? "Ext.encode(" : "",
                                     mode == ParameterMode.Raw ? script : JSON.Serialize(script), this.Encode ? ")" : ""));
            }
        }
示例#8
0
        public virtual string ToConfigString()
        {
            if (this.Format != RendererFormat.None)
            {
                if (this.FormatArgs != null && this.FormatArgs.Length > 0)
                {
                    return(new JFunction(
                               string.Concat(
                                   "return Ext.util.Format.",
                                   StringUtils.ToLowerCamelCase(this.Format.ToString()),
                                   "(value,",
                                   StringUtils.Concat(this.FormatArgs),
                                   ");"), "value").ToString());
                }

                if (string.IsNullOrEmpty(this.Handler))
                {
                    return(string.Concat("Ext.util.Format.", StringUtils.ToLowerCamelCase(this.Format.ToString())));
                }
            }

            if (!string.IsNullOrEmpty(this.Handler))
            {
                string temp = TokenUtils.ParseTokens(this.Handler, this.Owner);

                if (TokenUtils.IsRawToken(temp))
                {
                    return(TokenUtils.ReplaceRawToken(temp));
                }

                return(new JFunction(
                           temp,
                           new string[] { "value", "metadata", "record", "rowIndex", "colIndex", "store" })
                       .ToString());
            }

            return(TokenUtils.ReplaceRawToken(TokenUtils.ParseTokens(this.Fn)));
        }
示例#9
0
        public static void Redirect(string url, string msg, string msgCls)
        {
            ScriptManager sm = ScriptManager.GetInstance(HttpContext.Current);

            if (sm == null)
            {
                throw new InvalidOperationException("The ScriptManager can not be found during the Ext.Redirect.");
            }

            if (string.IsNullOrEmpty(url))
            {
                throw new ArgumentNullException("url", "The redirection url is empty");
            }

            if (!string.IsNullOrEmpty(msg))
            {
                Mask.Show(new Mask.Config {
                    Msg    = msg,
                    MsgCls = msgCls
                });
            }

            sm.AddScript(string.Concat("window.location=\"", (Coolite.Utilities.UrlUtils.IsUrl(url) || sm.Page == null || TokenUtils.IsRawToken(url)) ? url : sm.Page.ResolveUrl(url), "\";"));
        }