public static void Render(UserControlRendrerConfig config) { ResourceManager rm = ResourceManager.GetInstance(HttpContext.Current); var script = UserControlRenderer.ToScript(config); if (HttpContext.Current.CurrentHandler is Page && rm != null) { rm.AddScript(script); } else { new DirectResponse(script).Return(); } }
/// <summary> /// /// </summary> /// <param name="script"></param> protected virtual void RenderScript(string script) { if (HttpContext.Current == null) { return; } ResourceManager rm = ResourceManager.GetInstance(HttpContext.Current); if (HttpContext.Current.CurrentHandler is Page && rm != null) { rm.AddScript(script); } else { ResourceManager.AddInstanceScript(script); } }
/// <summary> /// /// </summary> /// <param name="nodes"></param> protected virtual void RegisterNodesIcons(NodeCollection nodes) { if (ResourceManager.HasResourceManager) { foreach (Node node in nodes) { if (node.Icon != Icon.None) { ResourceManager.GetInstance().RegisterIcon(node.Icon); } if (node.Children.Count > 0) { this.RegisterNodesIcons(node.Children); } } } }
protected virtual void RegisterNodesIcons(TreeNodeCollection nodes) { if (ResourceManager.HasResourceManager) { foreach (TreeNodeBase node in nodes) { if (node.Icon != Icon.None) { ResourceManager.GetInstance().RegisterIcon(node.Icon); } TreeNode treeNode = node as TreeNode; if (treeNode != null && treeNode.Nodes.Count > 0) { this.RegisterNodesIcons(treeNode.Nodes); } } } }
public DebugDescriptor(DebugConsole type) { this.type = type; string name = ""; switch (type) { case DebugConsole.Ext: name = "debug"; break; case DebugConsole.Firebug: name = "firebug-lite"; break; } ResourceManager rm = ResourceManager.GetInstance(HttpContext.Current); this.css = rm.GetWebResourceUrl(ResourceManager.ASSEMBLYSLUG + string.Concat(".ux.extensions.debug.", type.ToString().ToLowerInvariant(), ".css.", name, "-embedded.css")); this.script = rm.GetWebResourceUrl(ResourceManager.ASSEMBLYSLUG + string.Concat(".ux.extensions.debug.", type.ToString().ToLowerInvariant(), ".", name, ".js")); }
public virtual void AddScript(string script) { if (this.IsProxy || this.AlreadyRendered) { if (HttpContext.Current == null) { ResourceManager.AddInstanceScript(script); return; } ResourceManager rm = ResourceManager.GetInstance(HttpContext.Current); if (HttpContext.Current.CurrentHandler is Page && rm != null) { rm.AddScript(script); } else { ResourceManager.AddInstanceScript(script); } return; } if (script.IsNotEmpty() && !this.IsParentDeferredRender && this.Visible) { if (this.AlreadyRendered && this.HasResourceManager) { this.ResourceManager.RegisterOnReadyScript(ResourceManager.ScriptOrderNumber, TokenUtils.ReplaceRawToken(TokenUtils.ParseTokens(script, this))); } else { this.ProxyScripts.Add(ResourceManager.ScriptOrderNumber, TokenUtils.ReplaceRawToken(TokenUtils.ParseTokens(script, this))); } } }
protected override void Render(HtmlTextWriter writer) { base.Render(writer); switch (this.Mode) { case ResourceMode.Style: writer.Write(Transformer.NET.Net.CreateToken(typeof(Transformer.NET.AnchorTag), new Dictionary <string, string> { { "id", "ext.net.initstyle" } })); break; case ResourceMode.Script: ResourceManager rm = ResourceManager.GetInstance(); if (rm != null && rm.ScriptFilesContainer == null) { writer.Write(Transformer.NET.Net.CreateToken(typeof(Transformer.NET.AnchorTag), new Dictionary <string, string> { { "id", "ext.net.initscriptfiles" } })); } writer.Write(Transformer.NET.Net.CreateToken(typeof(Transformer.NET.AnchorTag), new Dictionary <string, string> { { "id", "ext.net.initscript" } })); break; case ResourceMode.ScriptFiles: writer.Write(Transformer.NET.Net.CreateToken(typeof(Transformer.NET.AnchorTag), new Dictionary <string, string> { { "id", "ext.net.initscriptfiles" } })); break; default: throw new ArgumentOutOfRangeException(); } }
public virtual void Confirm(string msg, string handler) { var tpl = @"(function(){{var result=confirm(""{0}"");{1}}})();"; ResourceManager.GetInstance(HttpContext.Current).AddScript(tpl, msg, handler); }
public static T Get <T>(string id) where T : BaseControl { return(ControlUtils.FindControl <T>(ResourceManager.GetInstance(HttpContext.Current), id)); }
public static BaseControl Get(string id) { return(ControlUtils.FindControl <BaseControl>(ResourceManager.GetInstance(HttpContext.Current), id)); }
public void GenerateProxy(StringBuilder sb, string controlID) { sb.Append(this.Attribute.Alias.IsEmpty() ? this.Name : this.Attribute.Alias); sb.Append(":function("); foreach (ParameterInfo parameterInfo in this.Params) { sb.Append(parameterInfo.Name); sb.Append(","); } sb.Append("config"); sb.Append("){"); sb.Append("Ext.net.DirectMethod.request(\""); sb.Append(this.Name); sb.Append("\",Ext.applyIf(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 (controlID.IsNotEmpty()) { 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 (this.Attribute.Msg.IsNotEmpty()) { sb.Append(",msg:").Append(JSON.Serialize(this.Attribute.Msg)); } if (this.Attribute.MsgCls.IsNotEmpty()) { sb.Append(",msgCls:").Append(JSON.Serialize(this.Attribute.MsgCls)); } if (this.Attribute.CustomTarget.IsNotEmpty()) { 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 && this.Attribute.CustomTarget.IsNotEmpty()) { ResourceManager sm = null; if (HttpContext.Current != null) { sm = ResourceManager.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 == DirectEventType.Load) { sb.Append(needComma ? "," : ""); sb.Append("type:\"load\""); needComma = true; } if (this.Attribute.ViewStateMode != ViewStateMode.Inherit) { sb.Append(needComma ? "," : ""); sb.AppendFormat("viewStateMode:\"{0}\"", this.Attribute.ViewStateMode.ToString().ToLowerInvariant()); needComma = true; } if (this.Attribute.RethrowException) { sb.Append(needComma ? "," : ""); sb.AppendFormat("rethrowException:{0}", this.Attribute.RethrowException.ToString().ToLowerInvariant()); needComma = true; } if (this.Attribute.Timeout != 30000) { sb.Append(needComma ? "," : ""); sb.AppendFormat("timeout:{0}", this.Attribute.Timeout); needComma = true; } if (this.Attribute.DisableCaching.HasValue) { sb.Append(needComma ? "," : ""); sb.AppendFormat("disableCaching:{0}", this.Attribute.DisableCaching.Value.ToString().ToLowerInvariant()); needComma = true; } if (this.Attribute.DisableCachingParam != "_dc") { sb.Append(needComma ? "," : ""); sb.AppendFormat("disableCachingParam:{0}", this.Attribute.DisableCachingParam); needComma = true; } if (this.Attribute.SuccessFn.IsNotEmpty()) { sb.Append(needComma ? "," : ""); sb.AppendFormat("success:{0}", this.Attribute.SuccessFn); needComma = true; } if (this.Attribute.CompleteFn.IsNotEmpty()) { sb.Append(needComma ? "," : ""); sb.AppendFormat("complete:{0}", this.Attribute.CompleteFn); needComma = true; } if (this.Attribute.FailureFn.IsNotEmpty()) { sb.Append(needComma ? "," : ""); sb.AppendFormat("failure:{0}", this.Attribute.FailureFn); } sb.Append("}));}"); }
public static string ReplaceDirectMethods(string script, Control seed) { if (TokenUtils.IsDirectMethodsToken(script)) { string ns = ResourceManager.GlobalNormalizedDirectMethodNamespace; #if MVC if (Ext.Net.MVC.MvcResourceManager.IsMVC || (seed is BaseControl && ((BaseControl)seed).IsMVC)) { if (HttpContext.Current != null && HttpContext.Current.Request.RequestContext.RouteData.DataTokens["area"] != null) { return(script.Replace(TokenUtils.Settings.DirectMethodsPattern, ns.ConcatWith(".", HttpContext.Current.Request.RequestContext.RouteData.DataTokens["area"].ToString()))); } return(script.Replace(TokenUtils.Settings.DirectMethodsPattern, ns)); } #endif UserControl parent = seed as UserControl; if (parent == null) { parent = ReflectionUtils.GetTypeOfParent(seed, typeof(System.Web.UI.UserControl)) as UserControl; } ResourceManager sm = null; if (parent != null && !(parent is MasterPage && seed.Parent is System.Web.UI.WebControls.ContentPlaceHolder)) { string id = ResourceManager.GetControlIdentification(parent, null); if (id.IsNotEmpty()) { id = ".".ConcatWith(id); } sm = ResourceManager.GetInstance(HttpContext.Current); if (sm != null) { ns = sm.NormalizedDirectMethodNamespace; } return(script.Replace(TokenUtils.Settings.DirectMethodsPattern, ns.ConcatWith(id))); } else { Page parentPage = seed as Page; if (parentPage == null) { parentPage = ReflectionUtils.GetTypeOfParent(seed, typeof(System.Web.UI.Page)) as System.Web.UI.Page; } sm = ResourceManager.GetInstance(); if (sm != null) { ns = sm.NormalizedDirectMethodNamespace; } return(script.Replace(TokenUtils.Settings.DirectMethodsPattern, ns)); } } return(script); }
private static string FormatArgs(object[] args) { StringBuilder sb = new StringBuilder(); if (args != null && args.Length > 0) { foreach (object arg in args) { if (arg is string) { sb.AppendFormat("{0},", TokenUtils.ParseAndNormalize(arg.ToString(), ResourceManager.GetInstance(HttpContext.Current))); } else { sb.AppendFormat("{0},", JSON.Serialize(arg)); } } } return(sb.ToString().LeftOfRightmostOf(',')); }
protected List <XControl> FindControls(Control seed, bool searchOnly, StringBuilder sb, List <Icon> icons) { if (seed == null) { return(null); } ResourceManager manager = ResourceManager.GetInstance(HttpContext.Current); if (icons == null) { icons = new List <Icon>(); } if (sb != null && !searchOnly && manager != null) { try { List <UserControl> userControls = ControlUtils.FindControls <UserControl>(this.Control); foreach (UserControl userControl in userControls) { manager.AddDirectMethodControl(userControl, true); } string proxies = manager.BuildDirectMethodProxies(true); foreach (UserControl userControl in userControls) { manager.RemoveDirectMethodControl(userControl, true); } if (!string.IsNullOrEmpty(proxies)) { sb.Append(proxies); } } catch (Exception e) { } } if (ReflectionUtils.IsTypeOf(seed, typeof(XControl), false)) { XControl ctrl = (XControl)seed; if (!searchOnly) { this.CheckIcon(ctrl, icons); this.CheckResources(ctrl); } ctrl.IsDynamic = true; ctrl.EnsureChildControlsInternal(); if (!searchOnly) { ctrl.CallOnPreRender(); ctrl.RegisterStyles(manager); ctrl.RegisterScripts(manager); } } List <XControl> foundControls = new List <XControl>(); foreach (Control control in seed.Controls) { if (this.ExcludeControl(seed, control)) { continue; } if (ReflectionUtils.IsTypeOf(control, typeof(XControl), false)) { XControl ctrl = (XControl)control; if (!searchOnly) { this.CheckIcon(ctrl, icons); this.CheckResources(ctrl); } foundControls.Add(ctrl); ctrl.IsDynamic = true; ctrl.EnsureChildControlsInternal(); if (!searchOnly) { ctrl.CallOnPreRender(); ctrl.RegisterStyles(manager); ctrl.RegisterScripts(manager); } } if (ControlUtils.HasControls(control)) { foundControls.AddRange(this.FindControls(control, searchOnly, null, icons)); } } if (sb != null && !searchOnly && icons.Count > 0) { string[] arr = new string[icons.Count]; for (int i = 0; i < icons.Count; i++) { arr[i] = icons[i].ToString(); } sb.Append("Ext.net.ResourceMgr.registerIcon("); sb.Append(JSON.Serialize(arr)); sb.Append(");"); sb.Append(script); } return(foundControls); }
public static AbstractComponent Get(string id) { return(ControlUtils.FindControl <AbstractComponent>(ResourceManager.GetInstance(HttpContext.Current), id)); }