public virtual void AddScript(string script) { if (!string.IsNullOrEmpty(script) && !this.IsParentDeferredRender && this.Visible) { this.ProxyScripts.Add(ScriptManager.ScriptOrderNumber, TokenUtils.ReplaceRawToken(TokenUtils.ParseTokens(script, this))); } }
public static string NormalizeRawToken(string script) { if (TokenUtils.IsRawToken(script)) { return(TokenUtils.ReplaceRawToken(script)); } return(string.Concat("\"", script, "\"")); }
protected override void OnPreRender(EventArgs e) { if (!this.DesignMode) { this.Controls.Add(new LiteralControl(TokenUtils.ReplaceRawToken(TokenUtils.ParseTokens(this.ScriptBlock, this)))); } base.OnPreRender(e); }
protected string ParseTarget(string target) { string parsedTarget = TokenUtils.ParseTokens(target, this); if (TokenUtils.IsRawToken(parsedTarget)) { return(TokenUtils.ReplaceRawToken(parsedTarget)); } return(string.Concat("\"", parsedTarget, "\"")); }
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)); }
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 ? ")" : "")); } }
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); }
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 ? ")" : "")); } }
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))); }
public void GenerateProxy(StringBuilder sb, string controlID) { sb.Append(this.Name); sb.Append(":function("); foreach (ParameterInfo parameterInfo in this.Params) { sb.Append(parameterInfo.Name); sb.Append(","); } sb.Append("config"); sb.Append("){"); sb.Append("Coolite.AjaxMethod.request(\""); sb.Append(this.Name); sb.Append("\",Ext.apply(config || {}, {"); int index = 0; bool needComma = false; if (this.Params.Length > 0) { sb.Append("params:{"); foreach (ParameterInfo parameterInfo in this.Params) { sb.Append(parameterInfo.Name); sb.Append(":"); sb.AppendFormat(parameterInfo.Name); index++; if (index < this.Params.Length) { sb.Append(","); } } sb.Append("}"); needComma = true; } if (this.Method.IsStatic) { sb.Append(needComma ? "," : ""); sb.Append("specifier:\"static\""); needComma = true; } if (!string.IsNullOrEmpty(controlID)) { sb.Append(needComma ? "," : ""); sb.AppendFormat("control:\"{0}\"", controlID); needComma = true; } if (this.Attribute.Method == HttpMethod.GET) { sb.Append(needComma ? "," : ""); sb.Append("method:\"GET\""); needComma = true; } if (this.Attribute.ShowMask) { sb.Append(needComma ? "," : ""); sb.Append("eventMask:{showMask:true"); if (!string.IsNullOrEmpty(this.Attribute.Msg)) { sb.Append(",msg:").Append(JSON.Serialize(this.Attribute.Msg)); } if (!string.IsNullOrEmpty(this.Attribute.MsgCls)) { sb.Append(",msgCls:").Append(JSON.Serialize(this.Attribute.MsgCls)); } if (!string.IsNullOrEmpty(this.Attribute.CustomTarget)) { this.Attribute.Target = MaskTarget.CustomTarget; } if (this.Attribute.Target != MaskTarget.Page) { sb.Append(",target:").Append(JSON.Serialize(this.Attribute.Target.ToString().ToLower())); } if (this.Attribute.Target == MaskTarget.CustomTarget && !string.IsNullOrEmpty(this.Attribute.CustomTarget)) { ScriptManager sm = null; if (HttpContext.Current != null) { sm = ScriptManager.GetInstance(HttpContext.Current); } string script = TokenUtils.ReplaceRawToken((sm != null) ? TokenUtils.ParseTokens(this.Attribute.CustomTarget, sm) : TokenUtils.ParseAndNormalize(this.Attribute.CustomTarget)); sb.Append(",customTarget:").Append(script); //sb.Append(",customTarget:").Append(JSON.Serialize(this.Attribute.CustomTarget)); } sb.Append("}"); needComma = true; } if (this.Attribute.Type == AjaxEventType.Load) { sb.Append(needComma ? "," : ""); sb.Append("type:\"load\""); needComma = true; } if (this.Attribute.ViewStateMode != ViewStateMode.Default) { sb.Append(needComma ? "," : ""); sb.AppendFormat("viewStateMode:\"{0}\"", this.Attribute.ViewStateMode.ToString().ToLowerInvariant()); needComma = true; } if (this.Attribute.Timeout != 30000) { sb.Append(needComma ? "," : ""); sb.AppendFormat("timeout:{0}", this.Attribute.Timeout); needComma = true; } if (!string.IsNullOrEmpty(this.Attribute.SuccessFn)) { sb.Append(needComma ? "," : ""); sb.AppendFormat("success:{0}", this.Attribute.SuccessFn); needComma = true; } if (!string.IsNullOrEmpty(this.Attribute.FailureFn)) { sb.Append(needComma ? "," : ""); sb.AppendFormat("failure:{0}", this.Attribute.FailureFn); } sb.Append("}));}"); }