public void CreateActionJavaScript(string methodName, StringCollection code, StringCollection parameters, string returnReceiver) { IJavascriptType ijt = this.ObjectInstance as IJavascriptType; if (ijt == null) { Type t = this.ObjectInstance as Type; if (t != null) { if (t.GetInterface("IJavascriptType") != null) { ijt = Activator.CreateInstance(t) as IJavascriptType; } } } if (ijt != null) { string m = ijt.GetJavascriptMethodRef(this.GetJavaScriptReferenceCode(code), methodName, code, parameters); if (!string.IsNullOrEmpty(m)) { if (string.IsNullOrEmpty(returnReceiver)) { code.Add(string.Format(CultureInfo.InvariantCulture, "{0};\r\n", m)); } else { code.Add(string.Format(CultureInfo.InvariantCulture, "{0}={1};\r\n", returnReceiver, m)); } return; } } WebPageCompilerUtility.CreateActionJavaScript(this.GetJavaScriptReferenceCode(code), methodName, code, parameters, returnReceiver); }
public override void CreateActionJavaScript(string methodName, StringCollection code, StringCollection parameters, string returnReceiver) { if (string.CompareOrdinal(methodName, "IsFileTypeValid") == 0) { if (!string.IsNullOrEmpty(returnReceiver)) { code.Add(string.Format(CultureInfo.InvariantCulture, "{0}=({1}.value.split('.').pop().toLowerCase()>=0);\r\n", returnReceiver, WebPageCompilerUtility.JsCodeRef(CodeName))); } } else if (string.CompareOrdinal(methodName, "IsFileSizeValid") == 0) { if (!string.IsNullOrEmpty(returnReceiver)) { code.Add(string.Format(CultureInfo.InvariantCulture, "{0}={1}.jsData.IsFileSizeValid();\r\n", returnReceiver, WebPageCompilerUtility.JsCodeRef(CodeName))); } } else if (string.CompareOrdinal(methodName, "SetMaxFileSize") == 0) { code.Add(string.Format(CultureInfo.InvariantCulture, "{0}.jsData.SetMaxFileSize({1});\r\n", WebPageCompilerUtility.JsCodeRef(CodeName), parameters[0])); } else { WebPageCompilerUtility.CreateActionJavaScript(WebPageCompilerUtility.JsCodeRef(CodeName), methodName, code, parameters, returnReceiver); } }
public static string ObjectCreateJavaScriptCode(object v) { if (v == null || v == System.DBNull.Value) { return("null"); } Type t = v.GetType(); if (typeof(bool).Equals(t)) { bool c = Convert.ToBoolean(v); if (c) { return("true"); } else { return("false"); } } if (typeof(Color).Equals(t)) { Color c = (Color)v; return(string.Format(CultureInfo.InvariantCulture, "'{0}'", WebPageCompilerUtility.GetColorString(c))); } if (typeof(Font).Equals(t)) { Font ft = (Font)v; return(string.Format(CultureInfo.InvariantCulture, "'{0}'", WebPageCompilerUtility.GetFontStyleString(ft))); } if (typeof(Cursor).Equals(t)) { return(string.Format(CultureInfo.InvariantCulture, "'{0}'", WebPageCompilerUtility.GetJavascriptCursorValue((Cursor)v, true))); } if (VPLUtil.IsNumber(t)) { return(v.ToString()); } if (t.IsArray) { Array a = v as Array; StringBuilder sb = new StringBuilder("["); if (a.Length > 0) { sb.Append(ObjectCreateJavaScriptCode(a.GetValue(0))); for (int i = 1; i < a.Length; i++) { sb.Append(","); sb.Append(ObjectCreateJavaScriptCode(a.GetValue(i))); } } sb.Append("]"); return(sb.ToString()); } return(string.Format(CultureInfo.InvariantCulture, "'{0}'", v)); }
public override void CreateActionJavaScript(string methodName, StringCollection code, StringCollection parameters, string returnReceiver) { if (typeof(HtmlElement_BodyBase).IsAssignableFrom(this.ParameterLibType)) { HtmlElement_BodyBase.CompilerCreateActionJavaScript(this.GetJavaScriptReferenceCode(code), methodName, code, parameters, returnReceiver); } else { WebPageCompilerUtility.CreateActionJavaScript(this.GetJavaScriptReferenceCode(code), methodName, code, parameters, returnReceiver); } }
public void CreateActionJavaScript(string methodName, StringCollection code, StringCollection parameters, string returnReceiver) { if (_pointer != null) { _pointer.CreateActionJavaScript(methodName, code, parameters, returnReceiver); } else if (_memberPointer != null) { _memberPointer.CreateActionJavaScript(methodName, code, parameters, returnReceiver); } else { WebPageCompilerUtility.CreateActionJavaScript(this.GetJavaScriptReferenceCode(code), methodName, code, parameters, returnReceiver); } }
public override string GetJavaScriptReferenceCode(StringCollection method, string attributeName, string[] parameters) { if (string.CompareOrdinal(attributeName, "IsFileTypeValid") == 0) { return(string.Format(CultureInfo.InvariantCulture, "{0}.toLowerCase().indexOf({1}.{2}.value.split('.').pop().toLowerCase()) >= 0", parameters[0], this.FormName, Site.Name)); } if (string.CompareOrdinal(attributeName, "IsFileSizeValid") == 0) { return(string.Format(CultureInfo.InvariantCulture, "{0}.jsData.IsFileSizeValid({1})", Site.Name, parameters[0])); } string s = WebPageCompilerUtility.GetJavaScriptWebMethodReferenceCode(WebPageCompilerUtility.JsCodeRef(CodeName), attributeName, method, parameters); if (!string.IsNullOrEmpty(s)) { return(s); } return(null); }
public void CreateActionJavaScript(string methodName, StringCollection code, StringCollection parameters, string returnReceiver) { if (ClassType != null && _type.BaseClassType.GetInterface("IJavascriptType") != null) { IJavascriptType js = Activator.CreateInstance(_type.BaseClassType) as IJavascriptType; string v = js.GetJavascriptMethodRef(this.CodeName, methodName, code, parameters); if (string.IsNullOrEmpty(returnReceiver)) { } else { code.Add(returnReceiver); code.Add("="); } code.Add(v); code.Add(";\r\n"); } else if (this.BaseClassType.IsArray) { if (string.CompareOrdinal(methodName, "Set") == 0) { code.Add(CodeName); code.Add("["); code.Add(parameters[0]); code.Add("]="); code.Add(parameters[1]); code.Add(";\r\n"); } else if (string.CompareOrdinal(methodName, "Get") == 0) { if (!string.IsNullOrEmpty(returnReceiver)) { code.Add(string.Format(CultureInfo.InvariantCulture, "{0}={1}[{2}];\r\n", returnReceiver, this.GetJavaScriptReferenceCode(code), parameters[0])); } } } else { WebPageCompilerUtility.CreateActionJavaScript(this.CodeName, methodName, code, parameters, returnReceiver); } }
void Obj_OnNameChanging(object sender, EventArgs e) { EventArgNameChange en = (EventArgNameChange)e; TreeNode nd = this.Parent; if (nd != null) { for (int i = 0; i < nd.Nodes.Count; i++) { if (i != this.Index) { if (string.CompareOrdinal(nd.Nodes[i].Text, en.NewName) == 0) { MessageBox.Show(this.TreeView != null ? this.TreeView.FindForm() : null, "The component name is already used", "Reanme", MessageBoxButtons.OK, MessageBoxIcon.Error); en.Cancel = true; } } } if (!en.Cancel) { NameCreation nc = new NameCreation(); if (!nc.IsValidName(en.NewName)) { MessageBox.Show(this.TreeView != null ? this.TreeView.FindForm() : null, "Invalid component name", "Reanme", MessageBoxButtons.OK, MessageBoxIcon.Error); en.Cancel = true; } } if (!en.Cancel) { string sn = en.NewName.ToLowerInvariant(); if (WebPageCompilerUtility.IsReservedPhpWord(sn)) { MessageBox.Show(this.TreeView != null ? this.TreeView.FindForm() : null, "Invalid component name. It is a reserved word.", "Reanme", MessageBoxButtons.OK, MessageBoxIcon.Error); en.Cancel = true; } } } }
public string GetJavaScriptWebMethodReferenceCode(string ownerCodeName, string methodName, System.Collections.Specialized.StringCollection code, System.Collections.Specialized.StringCollection parameters) { return(WebPageCompilerUtility.GetJavaScriptWebMethodReferenceCode(ownerCodeName, methodName, code, parameters)); }
public void CreateActionJavaScript(string methodName, StringCollection code, StringCollection parameters, string returnReceiver) { WebPageCompilerUtility.CreateActionJavaScript(this.GetJavaScriptReferenceCode(code), methodName, code, parameters, returnReceiver); }
public static void CreateJavaScript(IProperty SetProperty, string v, StringCollection sb, StringCollection parameters) { if (SetProperty.RootPointer != null && typeof(WebPage).IsAssignableFrom(SetProperty.RootPointer.BaseClassType)) { ClassPointer pp = SetProperty.PropertyOwner as ClassPointer; if (pp != null) { if (pp.ClassId != SetProperty.RootPointer.ClassId) { sb.Add(string.Format(CultureInfo.InvariantCulture, "JsonDataBinding.setPropertyByPageId({0},'{1}',{2});\r\n", pp.ClassId, SetProperty.Name, v)); return; } } } if (typeof(ProjectResources).Equals(SetProperty.Owner.ObjectInstance)) { if (string.CompareOrdinal(SetProperty.Name, "ProjectCultureName") == 0) { sb.Add(string.Format(CultureInfo.InvariantCulture, "JsonDataBinding.SwitchCulture({0});\r\n", v)); return; } } IWebClientComponent wcc = SetProperty.Owner.ObjectInstance as IWebClientComponent; if (wcc == null && SetProperty.Owner.ObjectInstance == null) { if (SetProperty.Owner.ObjectType != null) { if (SetProperty.Owner.ObjectType.GetInterface("IWebClientComponent") != null) { try { wcc = Activator.CreateInstance(SetProperty.Owner.ObjectType) as IWebClientComponent; if (wcc != null) { wcc.SetCodeName(SetProperty.Owner.CodeName); } } catch { } } } } if (wcc != null) { v = wcc.MapJavaScriptVallue(SetProperty.Name, v); } IWebClientPropertyCustomSetter wpcs = SetProperty.Owner.ObjectInstance as IWebClientPropertyCustomSetter; if (wpcs == null && SetProperty.Owner.ObjectInstance == null) { wpcs = wcc as IWebClientPropertyCustomSetter; } if (wpcs != null) { string ownerCode = SetProperty.Owner.GetJavaScriptReferenceCode(sb); if (wpcs.CreateSetPropertyJavaScript(ownerCode, SetProperty.Name, v, sb)) { return; } } if (string.CompareOrdinal("Font", SetProperty.Name) == 0) { IWebClientControl webc = SetProperty.Owner.ObjectInstance as IWebClientControl; if (webc != null) { sb.Add(string.Format(CultureInfo.InvariantCulture, "JsonDataBinding.setFont({0},{1});\r\n", WebPageCompilerUtility.JsCodeRef(webc.CodeName), WebPageCompilerUtility.GetFontJavascriptValues(v))); return; } } if (typeof(SessionVariableCollection).Equals(SetProperty.Owner.ObjectType)) { sb.Add(string.Format(CultureInfo.InvariantCulture, "JsonDataBinding.setSessionVariable('{0}',{1});\r\n", SetProperty.Name, v)); return; } if (typeof(LimnorWebApp).IsAssignableFrom(SetProperty.Owner.ObjectType)) { if (string.CompareOrdinal(SetProperty.Name, "GlobalVariableTimeout") == 0) { sb.Add(string.Format(CultureInfo.InvariantCulture, "JsonDataBinding.setSessionTimeout({0});\r\n", v)); return; } } string code = null; IWebClientPropertyHolder wcph = SetProperty.Owner.ObjectInstance as IWebClientPropertyHolder; if (wcph != null) { code = wcph.CreateSetPropertyJavaScript(SetProperty.Owner.CodeName, SetProperty.Name, v); if (!string.IsNullOrEmpty(code)) { sb.Add(code); } } IWebClientPropertySetter wcps = SetProperty.Owner.ObjectInstance as IWebClientPropertySetter; if (string.IsNullOrEmpty(code)) { if (wcps == null || !wcps.UseCustomSetter(SetProperty.Name)) { string left = SetProperty.GetJavaScriptReferenceCode(sb); if (left.EndsWith(".innerText", StringComparison.Ordinal)) { code = string.Format(CultureInfo.InvariantCulture, "JsonDataBinding.SetInnerText({0},{1});\r\n", left.Substring(0, left.Length - 10), v); } else if (left.StartsWith("JsonDataBinding.GetInnerText(", StringComparison.Ordinal)) { string oc = SetProperty.Owner.GetJavaScriptReferenceCode(sb); code = string.Format(CultureInfo.InvariantCulture, "JsonDataBinding.SetInnerText({0},{1});\r\n", oc, v); } else if (left.EndsWith(".Opacity", StringComparison.Ordinal)) { code = string.Format(CultureInfo.InvariantCulture, "JsonDataBinding.setOpacity({0},{1});\r\n", left.Substring(0, left.Length - ".Opacity".Length), v); } else if (left.StartsWith("JsonDataBinding.getOpacity(", StringComparison.Ordinal)) { string oc = SetProperty.Owner.GetJavaScriptReferenceCode(sb); code = string.Format(CultureInfo.InvariantCulture, "JsonDataBinding.setOpacity({0},{1});\r\n", oc, v); } else if (left.EndsWith(".style.display", StringComparison.Ordinal)) { code = string.Format(CultureInfo.InvariantCulture, "JsonDataBinding.setVisible({0},{1});\r\n", left.Substring(0, left.Length - ".style.display".Length), v); } else { if (wcc != null && v != null) { if (string.CompareOrdinal(SetProperty.Name, "Top") == 0 || string.CompareOrdinal(SetProperty.Name, "Left") == 0 || string.CompareOrdinal(SetProperty.Name, "Height") == 0 || string.CompareOrdinal(SetProperty.Name, "Width") == 0) { if (!v.EndsWith("px", StringComparison.Ordinal)) { code = string.Format(CultureInfo.InvariantCulture, "{0}=({1})+'px';\r\n", left, v); } } } if (code == null && SetProperty.Holder != null) { if (typeof(HtmlListBox).Equals(SetProperty.Holder.ObjectType) || typeof(HtmlDropDown).Equals(SetProperty.Holder.ObjectType)) { if (string.CompareOrdinal(SetProperty.Name, "SelectedValue") == 0 || string.CompareOrdinal(SetProperty.Name, "selectedValue") == 0) { code = string.Format(CultureInfo.InvariantCulture, "JsonDataBinding.SetSelectedListValue({0},{1});\r\n", SetProperty.Holder.GetJavaScriptReferenceCode(sb), v); } else if (string.CompareOrdinal(SetProperty.Name, "SelectedItem") == 0 || string.CompareOrdinal(SetProperty.Name, "selectedItem") == 0) { code = string.Format(CultureInfo.InvariantCulture, "JsonDataBinding.SetSelectedListText({0},{1});\r\n", SetProperty.Holder.GetJavaScriptReferenceCode(sb), v); } } } if (code == null) { code = string.Format(CultureInfo.InvariantCulture, "{0}={1};\r\n", left, v); } } if (!string.IsNullOrEmpty(code)) { sb.Add(code); } } } bool isCustomValue = false; if (string.CompareOrdinal("tag", SetProperty.Name) == 0) { isCustomValue = true; } else if (wcc != null) { WebClientValueCollection cvc = wcc.CustomValues; if (cvc != null) { if (cvc.ContainsKey(SetProperty.Name)) { isCustomValue = true; } } } if (isCustomValue) { string ownerCode = SetProperty.Owner.GetJavaScriptReferenceCode(sb); sb.Add(string.Format(CultureInfo.InvariantCulture, "{0}JsonDataBinding.onSetCustomValue({1},'{2}');\r\n", Indentation.GetIndent(), ownerCode, SetProperty.Name)); } if (wcps != null) { wcps.OnSetProperty(SetProperty.Name, v, sb); } }