public override bool OnExportJavaScriptCode(ActionBranch previousAction, ActionBranch nextAction, StringCollection jsCode, StringCollection methodCode, JsMethodCompiler data) { string indexName = RepeatIndex.CodeName; methodCode.Add(Indentation.GetIndent()); methodCode.Add("for("); methodCode.Add(indexName); methodCode.Add("=0;"); methodCode.Add(indexName); methodCode.Add("<"); methodCode.Add(RepeatCount.CreateJavaScript(methodCode)); methodCode.Add(";"); methodCode.Add(indexName); methodCode.Add("++) {\r\n"); Indentation.IndentIncrease(); string indents = Indentation.GetIndent(); StringCollection sc = new StringCollection(); if (_iconList != null) { foreach (ComponentIcon ci in _iconList) { ComponentIconLocal cil = ci as ComponentIconLocal; if (cil != null && cil.ScopeGroupId == this.BranchId) { sc.Add(indents); sc.Add("var "); sc.Add(cil.LocalPointer.CodeName); sc.Add("="); sc.Add(ObjectCreationCodeGen.ObjectCreateJavaScriptCode(VPLUtil.GetDefaultValue(cil.LocalPointer.BaseClassType))); sc.Add(";\r\n"); } } } SetWithinLoop(); Method.SubMethod.Push(this); data.AddSubMethod(this); bool bRet = base.OnExportJavaScriptCode(previousAction, nextAction, jsCode, sc, data); Method.SubMethod.Pop(); // for (int i = 0; i < sc.Count; i++) { methodCode.Add(sc[i]); } Indentation.IndentDecrease(); methodCode.Add(Indentation.GetIndent()); methodCode.Add("}\r\n"); return(bRet); }
public override string CreateJavaScript(StringCollection method) { return(ObjectCreationCodeGen.ObjectCreateJavaScriptCode(_value)); }
public string GetValueJsCode() { return(ObjectCreationCodeGen.ObjectCreateJavaScriptCode(_value)); }
public override bool OnExportJavaScriptCode(ActionBranch previousAction, ActionBranch nextAction, StringCollection jsCode, StringCollection methodCode, JsMethodCompiler data) { string c; if (_logicExpression == null) { c = "true"; } else { _logicExpression.PrepareForCompile(this.Method); c = _logicExpression.CreateJavaScript(methodCode); } methodCode.Add(Indentation.GetIndent()); string initCodeStr = null; string increCodeStr = null; if (_initAction != null) { if (_initAction.Action == null) { _initAction.OnPostRootDeserialize(); } if (_initAction.Action != null) { StringCollection initCode = new StringCollection(); _initAction.Action.ExportJavaScriptCode(null, null, methodCode, initCode, data); StringBuilder sb = new StringBuilder(); for (int i = 0; i < initCode.Count; i++) { sb.Append(initCode[i]); } initCodeStr = sb.ToString().Replace("\r\n", ""); } } if (_increAction != null) { if (_increAction.Action == null) { _increAction.OnPostRootDeserialize(); } if (_increAction.Action != null) { StringCollection increCode = new StringCollection(); _increAction.Action.ExportJavaScriptCode(null, null, methodCode, increCode, data); StringBuilder sb = new StringBuilder(); for (int i = 0; i < increCode.Count; i++) { sb.Append(increCode[i]); } increCodeStr = sb.ToString().Replace("\r\n", ""); } } if (string.IsNullOrEmpty(initCodeStr)) { initCodeStr = ";"; } if (!string.IsNullOrEmpty(increCodeStr)) { increCodeStr = increCodeStr.Trim(); while (increCodeStr.EndsWith(";", StringComparison.Ordinal)) { increCodeStr = increCodeStr.Substring(0, increCodeStr.Length - 1); increCodeStr = increCodeStr.Trim(); } } methodCode.Add("for("); methodCode.Add(initCodeStr); methodCode.Add(c); methodCode.Add(";"); methodCode.Add(increCodeStr); methodCode.Add(") {\r\n"); Indentation.IndentIncrease(); string indents = Indentation.GetIndent(); StringCollection sc = new StringCollection(); if (_iconList != null) { foreach (ComponentIcon ci in _iconList) { ComponentIconLocal cil = ci as ComponentIconLocal; if (cil != null && cil.ScopeGroupId == this.BranchId) { sc.Add(indents); sc.Add("var "); sc.Add(cil.LocalPointer.CodeName); sc.Add("="); sc.Add(ObjectCreationCodeGen.ObjectCreateJavaScriptCode(VPLUtil.GetDefaultValue(cil.LocalPointer.BaseClassType))); sc.Add(";\r\n"); } } } Method.SubMethod.Push(this); data.AddSubMethod(this); bool bRet = base.OnExportJavaScriptCode(previousAction, nextAction, jsCode, sc, data); Method.SubMethod.Pop(); // for (int i = 0; i < sc.Count; i++) { methodCode.Add(sc[i]); } Indentation.IndentDecrease(); methodCode.Add(Indentation.GetIndent()); methodCode.Add("}\r\n"); return(bRet); }