private void CheckID() { if (((control.IDMode == Ext.Net.IDMode.Explicit || control.IDMode == Ext.Net.IDMode.Static) && !control.IsIdRequired) || control.IDMode == Ext.Net.IDMode.Ignore) { throw new Exception("You have to set widget's ID to call its methods (widget - " + control.GetType().ToString() + ")"); } }
public string GetScript(BaseControl c, PropertyInfo property) { StringBuilder sb = new StringBuilder(); if (!c.CallbackValues.ContainsKey(property.Name)) { return(null); } object value = c.CallbackValues[property.Name]; if (this.Script.IsNotEmpty()) { sb.AppendFormat(this.Script, c.ClientID, JSON.Serialize(value)); } else if (this.MethodName.IsNotEmpty()) { MethodInfo method = c.GetType().GetMethod(this.MethodName, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance, null, new Type[] { property.PropertyType }, null); if (method != null) { method.Invoke(c, new object[] { value }); } } else //simple script generating { switch (this.GenerateMode) { case AutoGeneratingScript.Simple: sb.AppendFormat(DirectEventUpdateAttribute.AutoGenerateFormat, c.ClientID, JSON.Serialize(value), property.Name.ToLowerCamelCase()); break; case AutoGeneratingScript.WithSet: sb.AppendFormat("{0}.set{2}({1});", c.ClientID, JSON.Serialize(value), property.Name); break; default: throw new ArgumentOutOfRangeException(); } } return(sb.ToString()); }
public string GetScript(BaseControl c, PropertyInfo property) { StringBuilder sb = new StringBuilder(); if (!c.CallbackValues.ContainsKey(property.Name)) { return null; } object value = c.CallbackValues[property.Name]; if (this.Script.IsNotEmpty()) { sb.AppendFormat(this.Script, c.ClientID, JSON.Serialize(value)); } else if (this.MethodName.IsNotEmpty()) { MethodInfo method = c.GetType().GetMethod(this.MethodName, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance, null, new Type[] { property.PropertyType }, null); if (method != null) { method.Invoke(c, new object[] { value }); } } else //simple script generating { switch (this.GenerateMode) { case AutoGeneratingScript.Simple: sb.AppendFormat(DirectEventUpdateAttribute.AutoGenerateFormat, c.ClientID, JSON.Serialize(value), property.Name.ToLowerCamelCase()); break; case AutoGeneratingScript.WithSet: sb.AppendFormat("{0}.set{2}({1});", c.ClientID, JSON.Serialize(value), property.Name); break; default: throw new ArgumentOutOfRangeException(); } } return sb.ToString(); }