public void CreateJavaScript(StringCollection sb, StringCollection parameters, string returnReceiver)
 {
     if (!(parameters != null && parameters.Count > 0))
     {
         bool babort = this.IsAbort;
         //why abort event handling? if a return isused in an event handler, it should stop all levels of goto's
         if (_ownerAction != null)
         {
             EventHandlerMethod ehm = _ownerAction.ActionHolder as EventHandlerMethod;
             if (ehm != null)
             {
                 babort = true;
             }
         }
         if (babort)
         {
             sb.Add("JsonDataBinding.AbortEvent = true;\r\n");
         }
     }
     sb.Add(Indentation.GetIndent());
     sb.Add("return");
     if (parameters != null && parameters.Count > 0)
     {
         sb.Add(" ");
         sb.Add(parameters[0]);
     }
     sb.Add(";\r\n");
 }
 public override bool OnExportJavaScriptCode(ActionBranch previousAction, ActionBranch nextAction, StringCollection jsCode, StringCollection methodCode, JsMethodCompiler data)
 {
     if (_eventAction != null)
     {
         _eventAction.AttachJavascriptAction(this.BranchId, methodCode, Indentation.GetIndent());
     }
     return(false);
 }
        public override bool OnExportPhpScriptCode(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("$");
                        sc.Add(cil.LocalPointer.CodeName);
                        sc.Add("=");
                        sc.Add(ValueTypeUtil.GetDefaultPhpScriptValueByType(cil.LocalPointer.BaseClassType));
                        sc.Add(";\r\n");
                    }
                }
            }
            SetWithinLoop();
            Method.SubMethod.Push(this);
            data.AddSubMethod(this);
            bool bRet = base.OnExportPhpScriptCode(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 void ExportJavaScriptCode(ActionBranch currentAction, ActionBranch nextAction, StringCollection jsCode, StringCollection methodToCompile, JsMethodCompiler data)
 {
     CreateJavaScript(methodToCompile, data.FormSubmissions, nextAction == null ? null : nextAction.InputName, Indentation.GetIndent());
 }
Beispiel #5
0
        public override bool OnExportPhpScriptCode(ActionBranch previousAction, ActionBranch nextAction, StringCollection jsCode, StringCollection methodCode, JsMethodCompiler data)
        {
            if (IsCompiled)
            {
                return(false);
            }
            //preventing of compiling it twice
            IsCompiled = true;
            bool         isGotoPoint = this.IsGotoPoint;
            ActionBranch nt          = nextAction;

            if (_jumpToId != 0)
            {
                //next action is the one it jumps to
                nt = _jumpToActionBranch;
            }
            JsMethodSegment  ms0 = null;
            StringCollection sts = methodCode;

            if (isGotoPoint)
            {
                //two or more branches in the same thread linked to this branch
                //since goto-label must be in the method scope, not sub-scope, this branch code must be
                //in the method scope
                ms0 = data.GetGotoBranch(this.FirstActionId);
                if (ms0 == null)
                {
                    sts = new StringCollection();
                    ms0 = new JsMethodSegment(sts);
                    data.AddGotoBranch(this.FirstActionId, ms0);
                }
                else
                {
                    throw new DesignerException("Action list as goto branch {0} compiled twice", this.FirstActionId);
                }
                //use goto statement to jump to this branch is the responsibility of the branches jumping to it.
            }
            bool b0 = base.OnExportPhpScriptCode(previousAction, nt, jsCode, sts, data);

            if (ms0 != null)
            {
                ms0.Completed = b0;
            }
            if (b0)
            {
                return(true);
            }
            else
            {
                //not all sub-branches of this branch completed.
                //check jumping
                if (_jumpToId != 0)
                {
                    bool bRet = false;
                    //same thread: use goto or fall through; otherwise use waiting point
                    if (_jumpToActionBranch.StartingBranchId == this.StartingBranchId)
                    {
                        //a goto branch, use goto
                        if (_jumpToActionBranch.IsGotoPoint)
                        {
                            sts.Add(Indentation.GetIndent());
                            sts.Add("goto ");
                            sts.Add(ActionBranch.IdToLabel(_jumpToId));
                            sts.Add(";\r\n");
                            bRet = true;
                        }
                        if (!_jumpToActionBranch.IsCompiled)
                        {
                            if (_jumpToActionBranch.IsGotoPoint)
                            {
                                Indentation.IndentIncrease();
                            }
                            bool b = _jumpToActionBranch.ExportPhpScriptCode(this, null, jsCode, sts, data);
                            if (_jumpToActionBranch.IsGotoPoint)
                            {
                                Indentation.IndentDecrease();
                            }
                            if (!_jumpToActionBranch.IsGotoPoint)
                            {
                                bRet = b;
                            }
                        }
                    }
                    return(bRet);
                }
                else
                {
                    //not completed
                    return(false);
                }
            }
        }
        public override bool OnExportPhpScriptCode(ActionBranch previousAction, ActionBranch nextAction, StringCollection jsCode, StringCollection methodCode, JsMethodCompiler data)
        {
            string c;

            if (_logicExpression == null)
            {
                c = "true";
            }
            else
            {
                _logicExpression.PrepareForCompile(this.Method);
                c = _logicExpression.CreatePhpScript(methodCode);
            }
            methodCode.Add(Indentation.GetIndent());
            string initCodeStr  = null;
            string increCodeStr = null;

            if (_initAction != null && _initAction.Action != null)
            {
                StringCollection initCode = new StringCollection();
                _initAction.Action.ExportPhpScriptCode(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 && _increAction.Action != null)
            {
                StringCollection increCode = new StringCollection();
                _increAction.Action.ExportPhpScriptCode(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("$");
                        sc.Add(cil.LocalPointer.CodeName);
                        sc.Add("=");
                        sc.Add(ValueTypeUtil.GetDefaultPhpScriptValueByType(cil.LocalPointer.BaseClassType));
                        sc.Add(";\r\n");
                    }
                }
            }
            Method.SubMethod.Push(this);
            data.AddSubMethod(this);
            bool bRet = base.OnExportPhpScriptCode(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);
        }
Beispiel #7
0
        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);
            }
        }
Beispiel #8
0
 public override bool OnExportJavaScriptCode(ActionBranch previousAction, ActionBranch nextAction, StringCollection jsCode, StringCollection methodCode, JsMethodCompiler data)
 {
     if (_conditionAction != null)
     {
         if (IsCompiled)
         {
             return(false);
         }
         //preventing of compiling it twice
         IsCompiled = true;
         if (_conditionAction.TrueActions != null && _conditionAction.FalseActions != null && _conditionAction.TrueActions.BranchId == _conditionAction.FalseActions.BranchId)
         {
             throw new DesignerException("Condition action [{0}, {1}] goes to the same action", this.FirstActionBranchId, _conditionAction.Name);
         }
         try
         {
             StringCollection sts = methodCode;
             string           c;
             if (_conditionAction.Condition == null)
             {
                 c = "true";
             }
             else
             {
                 _conditionAction.Condition.SetDataType(typeof(bool));
                 c = _conditionAction.Condition.CreateJavaScript(sts);
             }
             bool   b1     = false;
             bool   b2     = false;
             string indent = Indentation.GetIndent();
             sts.Add(indent);
             sts.Add("if(");
             sts.Add(c);
             sts.Add(") {\r\n");
             if (_ifBlock != null)
             {
                 Indentation.IndentIncrease();
                 b1 = _ifBlock.OnExportJavaScriptCode(previousAction, null, jsCode, sts, data);
                 Indentation.IndentDecrease();
             }
             sts.Add(indent);
             sts.Add("}\r\n");
             if (_elseBlock != null)
             {
                 sts.Add(indent);
                 sts.Add("else {\r\n");
                 Indentation.IndentIncrease();
                 b2 = _elseBlock.OnExportJavaScriptCode(previousAction, null, jsCode, sts, data);
                 Indentation.IndentDecrease();
                 sts.Add(indent);
                 sts.Add("}\r\n");
             }
             if (_mergeBlock != null)
             {
                 return(_mergeBlock.OnExportJavaScriptCode(null, null, jsCode, sts, data));
             }
             else
             {
                 return(b1 && b2);
             }
         }
         catch (Exception err)
         {
             throw new DesignerException(err, "Error compiling Condition action {0}. See inner exception for details", _conditionAction.TraceInfo);
         }
     }
     return(false);
 }
        public override bool OnExportPhpScriptCode(ActionBranch previousAction, ActionBranch nextAction, StringCollection jsCode, StringCollection methodCode, JsMethodCompiler data)
        {
            bool bRet;

            if (_actionData == null)
            {
                _actionData = (ActionSubMethod)this.Method.GetActionInstance(_actId.ActionId);
            }
            SubMethodInfoPointer smi = _actionData.ActionMethod as SubMethodInfoPointer;
            SubMethodInfo        mi  = smi.MethodInformation as SubMethodInfo;

            if (mi == null)
            {
                return(false);
            }
            if (mi.IsForeach)
            {
                ParameterClassSubMethod p  = mi.GetParameterType(0, smi, this);
                StringBuilder           sb = new StringBuilder();
                string         s1          = smi.Owner.CodeName;
                IObjectPointer op          = smi.Owner;
                sb.Append(s1);
                while (!(op is ILocalvariable) && op.Owner != null && op.Owner.Owner != null)
                {
                    if (string.CompareOrdinal(s1, op.Owner.CodeName) != 0)
                    {
                        s1 = op.Owner.CodeName;
                        sb.Insert(0, "->");
                        sb.Insert(0, s1);
                    }
                    op = op.Owner;
                }
                if (op is ILocalvariable || op.Owner is ILocalvariable)
                {
                }
                else
                {
                    sb.Insert(0, "$this->");
                }
                s1 = sb.ToString();
                string indents = Indentation.GetIndent();
                string s0      = string.Format(System.Globalization.CultureInfo.InvariantCulture,
                                               "\r\n{2}foreach ({0} as {1}) {{\r\n", s1, p.CodeName, indents);
                methodCode.Add(s0);
                //
                Method.SubMethod.Push(this);
                data.AddSubMethod(this);
                Indentation.IndentIncrease();
                bRet = base.OnExportPhpScriptCode(previousAction, nextAction, jsCode, methodCode, data);
                Indentation.IndentDecrease();
                Method.SubMethod.Pop();
                //
                methodCode.Add(indents);
                methodCode.Add("}\r\n");
            }
            else
            {
                string         indents = Indentation.GetIndent();
                StringBuilder  sb      = new StringBuilder();
                string         s1      = smi.Owner.CodeName;
                IObjectPointer op      = smi.Owner;
                sb.Append(s1);
                while (!(op is ILocalvariable) && op.Owner != null && op.Owner.Owner != null)
                {
                    if (string.CompareOrdinal(s1, op.Owner.CodeName) != 0)
                    {
                        s1 = op.Owner.CodeName;
                        sb.Insert(0, "->");
                        sb.Insert(0, s1);
                    }
                    op = op.Owner;
                }
                if (op is ILocalvariable)
                {
                }
                else
                {
                    sb.Insert(0, "$this->");
                }
                s1 = sb.ToString();

                ParameterClassSubMethod p = mi.GetParameterType(1, smi, this);
                p.ParameterID = _actionData.ParameterValues[1].ParameterID;
                string v  = p.CodeName;
                string s0 = string.Format(System.Globalization.CultureInfo.InvariantCulture,
                                          "\r\n{3}foreach ({0} as {1} => {2} ) {{\r\n", s1, mi.GetIndexCodePHP(smi, this.BranchId), v, indents);
                methodCode.Add(s0);
                Method.SubMethod.Push(this);
                data.AddSubMethod(this);
                //
                Indentation.IndentIncrease();
                bRet = base.OnExportPhpScriptCode(previousAction, nextAction, jsCode, methodCode, data);
                Method.SubMethod.Pop();
                //
                Indentation.IndentDecrease();
                methodCode.Add(indents);
                methodCode.Add("}\r\n");
            }

            return(bRet);
        }
        public override bool OnExportJavaScriptCode(ActionBranch previousAction, ActionBranch nextAction, StringCollection jsCode, StringCollection methodCode, JsMethodCompiler data)
        {
            bool bRet;

            if (_actionData == null)
            {
                _actionData = (ActionSubMethod)this.Method.GetActionInstance(_actId.ActionId);                // (ActionSubMethod)compiler.ActionEventList.GetAction(_actId);
            }
            if (_actionData == null)
            {
                return(false);
            }
            SubMethodInfoPointer smi = _actionData.ActionMethod as SubMethodInfoPointer;
            SubMethodInfo        mi  = smi.MethodInformation as SubMethodInfo;

            if (mi == null)
            {
                return(false);
            }
            if (mi.IsForeach)
            {
                ParameterClassSubMethod p  = mi.GetParameterType(0, smi, this);
                StringBuilder           sb = new StringBuilder();
                string         s1          = smi.Owner.CodeName;
                IObjectPointer op          = smi.Owner;
                sb.Append(s1);
                while (!(op is ILocalvariable) && op.Owner != null && op.Owner.Owner != null)
                {
                    if (!s1.StartsWith(op.Owner.CodeName, StringComparison.Ordinal))
                    {
                        s1 = op.Owner.CodeName;
                        sb.Insert(0, ".");
                        sb.Insert(0, s1);
                    }
                    op = op.Owner;
                }
                s1 = sb.ToString();
                string indents = Indentation.GetIndent();
                string a       = string.Format(CultureInfo.InvariantCulture,
                                               "a{0}", Guid.NewGuid().GetHashCode().ToString("x", CultureInfo.InvariantCulture));
                string idx = string.Format(CultureInfo.InvariantCulture,
                                           "i{0}", Guid.NewGuid().GetHashCode().ToString("x", CultureInfo.InvariantCulture));
                string s0 = string.Format(System.Globalization.CultureInfo.InvariantCulture,
                                          "{4}var {3} = {1};\r\n{4}if({3}) for(var {0}=0;{0}<{3}.length;{0}++) {{\r\n{4}var {2}={3}[{0}]; \r\n", idx, s1, p.CodeName, a, indents);
                methodCode.Add(s0);
                Method.SubMethod.Push(this);
                data.AddSubMethod(this);
                Indentation.IndentIncrease();
                bRet = base.OnExportJavaScriptCode(previousAction, nextAction, jsCode, methodCode, data);
                Indentation.IndentDecrease();
                Method.SubMethod.Pop();
                //
                methodCode.Add(indents);
                methodCode.Add("}\r\n");
            }
            else
            {
                string indents = Indentation.GetIndent();
                methodCode.Add(indents);
                methodCode.Add("for(var ");
                methodCode.Add(mi.GetInitStatementJS(smi, jsCode, methodCode, data, this.BranchId));
                methodCode.Add(mi.GetTestExpressionJS(smi, jsCode, methodCode, data, this.BranchId));
                methodCode.Add(mi.GetIncrementalStatementJS(smi, jsCode, methodCode, data, this.BranchId));
                methodCode.Add(") {\r\n");
                Method.SubMethod.Push(this);
                data.AddSubMethod(this);
                Indentation.IndentIncrease();
                if (_iconList != null)
                {
                    foreach (ComponentIcon ci in _iconList)
                    {
                        ComponentIconLocal cil = ci as ComponentIconLocal;
                        if (cil != null && cil.ScopeGroupId == this.BranchId)
                        {
                            methodCode.Add(Indentation.GetIndent());
                            methodCode.Add("var ");
                            methodCode.Add(cil.LocalPointer.CodeName);
                            methodCode.Add("=");
                            methodCode.Add(ValueTypeUtil.GetDefaultJavaScriptValueByType(cil.LocalPointer.BaseClassType));
                            methodCode.Add(";\r\n");
                        }
                    }
                }
                bRet = base.OnExportJavaScriptCode(previousAction, nextAction, jsCode, methodCode, data);
                Method.SubMethod.Pop();
                //
                Indentation.IndentDecrease();
                methodCode.Add(indents);
                methodCode.Add("}\r\n");
            }

            return(bRet);
        }
        public override bool OnExportCode(ActionBranch previousAction, ActionBranch nextAction, ILimnorCodeCompiler compiler, CodeMemberMethod method, CodeStatementCollection statements)
        {
            bool bRet;

            if (_actionData == null)
            {
                _actionData = (ActionSubMethod)this.Method.GetActionInstance(_actId.ActionId);                // (ActionSubMethod)compiler.ActionEventList.GetAction(_actId);
            }
            SubMethodInfoPointer smi = _actionData.ActionMethod as SubMethodInfoPointer;
            SubMethodInfo        mi  = smi.MethodInformation as SubMethodInfo;

            if (mi.IsForeach)
            {
                ParameterClassSubMethod p  = mi.GetParameterType(0, smi, this);
                StringBuilder           sb = new StringBuilder();
                string s1 = smi.Owner.CodeName;
                CustomMethodParameterPointer cmpp = smi.Owner.Owner as CustomMethodParameterPointer;
                if (cmpp == null)
                {
                    IObjectPointer op = smi.Owner;
                    sb.Append(s1);
                    while (!(op is ILocalvariable) && op.Owner != null && !(op.Owner is MethodClass) && op.Owner.Owner != null)
                    {
                        if (string.CompareOrdinal(s1, op.Owner.CodeName) != 0)
                        {
                            s1 = op.Owner.CodeName;
                            sb.Insert(0, ".");
                            sb.Insert(0, s1);
                        }
                        op = op.Owner;
                    }
                    s1 = sb.ToString();
                }
                string itemTypeString = null;
                if (mi.ItemType.IsGenericParameter)
                {
                    CollectionPointer cp = smi.Owner as CollectionPointer;
                    if (cp != null)
                    {
                        CustomPropertyPointer cpp = cp.Owner as CustomPropertyPointer;
                        if (cpp != null)
                        {
                            DataTypePointer dtp = cpp.GetConcreteType(mi.ItemType);
                            if (dtp != null)
                            {
                                itemTypeString = dtp.TypeString;
                            }
                        }
                    }
                }
                if (string.IsNullOrEmpty(itemTypeString))
                {
                    itemTypeString = VPLUtil.GetTypeCSharpName(mi.ItemType);
                }
                string s0 = string.Format(System.Globalization.CultureInfo.InvariantCulture,
                                          "{0}foreach({1} {2} in {3}) {{", Indentation.GetIndent(), itemTypeString, p.CodeName, s1);
                CodeStatement cis0 = new CodeSnippetStatement(s0);
                statements.Add(cis0);
                //
                if (_iconList != null)
                {
                    foreach (ComponentIcon ci in _iconList)
                    {
                        ComponentIconLocal cil = ci as ComponentIconLocal;
                        if (cil != null && cil.ScopeGroupId == this.BranchId)
                        {
                            cil.LocalPointer.AddVariableDeclaration(statements);
                        }
                    }
                }
                //
                CodeStatementCollection sc = new CodeStatementCollection();
                Method.SubMethod.Push(this);                //smi);
                CompilerUtil.AddSubMethod(method, this);
                bRet = base.OnExportCode(previousAction, nextAction, compiler, method, sc);
                Method.SubMethod.Pop();

                bRet = CompilerUtil.FinishSubMethod(method, this, sc, bRet);
                statements.AddRange(sc);
                //
                statements.Add(new CodeSnippetStatement(string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0}}}", Indentation.GetIndent())));
            }
            else
            {
                CodeIterationStatement cis = new CodeIterationStatement();
                cis.TestExpression     = mi.GetTestExpression(smi, compiler, this.Method, method, statements, this.BranchId);
                cis.InitStatement      = mi.GetInitStatement(smi, compiler, this.Method, method, statements, this.BranchId);
                cis.IncrementStatement = mi.GetIncrementalStatement(smi, compiler, this.Method, method, statements, this.BranchId);
                //
                Method.SubMethod.Push(this);                //smi);
                CompilerUtil.AddSubMethod(method, this);
                if (_iconList != null)
                {
                    foreach (ComponentIcon ci in _iconList)
                    {
                        ComponentIconLocal cil = ci as ComponentIconLocal;
                        if (cil != null && cil.ScopeGroupId == this.BranchId)
                        {
                            cil.LocalPointer.AddVariableDeclaration(cis.Statements);
                        }
                    }
                }
                bRet = base.OnExportCode(previousAction, nextAction, compiler, method, cis.Statements);
                Method.SubMethod.Pop();

                bRet = CompilerUtil.FinishSubMethod(method, this, cis.Statements, bRet);
                //
                //
                statements.Add(cis);
            }

            return(bRet);
        }