/// <summary>
        ///
        /// </summary>
        /// <param name="previousAction"></param>
        /// <param name="nextAction"></param>
        /// <param name="compiler"></param>
        /// <param name="method"></param>
        /// <param name="statements"></param>
        public override bool OnExportCode(ActionBranch previousAction, ActionBranch nextAction, ILimnorCodeCompiler compiler, CodeMemberMethod method, CodeStatementCollection statements)
        {
            string                 indexName = RepeatIndex.CodeName;
            CodeExpression         c         = new CodeBinaryOperatorExpression(new CodeVariableReferenceExpression(indexName), CodeBinaryOperatorType.LessThan, RepeatCount.GetReferenceCode(Method, statements, true));
            CodeIterationStatement cis       = new CodeIterationStatement();

            cis.TestExpression     = c;
            cis.InitStatement      = new CodeVariableDeclarationStatement(typeof(int), indexName, new CodePrimitiveExpression(0));
            cis.IncrementStatement = new CodeSnippetStatement(indexName + "++");
            statements.Add(cis);
            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);
                    }
                }
            }
            SetWithinLoop();
            Method.SubMethod.Push(this);
            CompilerUtil.AddSubMethod(method, this);
            bool bRet = base.OnExportCode(previousAction, nextAction, compiler, method, cis.Statements);

            Method.SubMethod.Pop();
            bRet = CompilerUtil.FinishSubMethod(method, this, cis.Statements, bRet);
            return(bRet);
        }
 public LocalVarPointer(ComponentIconLocal icon, MethodClass method)
 {
     _method = method;
     //_memberId = icon.MemberId;
     //_classId = method.ClassId;
     //_name = icon.Name;
     _pointer = icon.ClassPointer;
     _img     = icon.IconImage;
 }
        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);
        }
示例#4
0
        public void RemoveLocalVariable(ComponentIconLocal v, List <UInt32> usedBranches)
        {
            if (usedBranches.Contains(this.BranchId))
            {
                return;
            }
            usedBranches.Add(this.BranchId);
            ISubMethod af = this as ISubMethod;

            if (af != null)
            {
                af.ComponentIconList.Remove(v);
                if (v.ClassPointer != null)
                {
                    ComponentIconLocal cx = null;
                    foreach (ComponentIcon c in af.ComponentIconList)
                    {
                        ComponentIconLocal c0 = c as ComponentIconLocal;
                        if (c0 != null && c0.ClassPointer != null)
                        {
                            if (c0.ClassPointer.IsSameObjectRef(v.ClassPointer))
                            {
                                cx = c0;
                                break;
                            }
                        }
                    }
                    if (cx != null)
                    {
                        af.ComponentIconList.Remove(cx);
                    }
                }
            }
            BranchList acts = ActionList;

            if (acts != null)
            {
                foreach (ActionBranch ab in acts)
                {
                    AB_Squential abs = ab as AB_Squential;
                    if (abs != null)
                    {
                        abs.RemoveLocalVariable(v, usedBranches);
                    }
                }
            }
        }
 public override LocalVariable GetLocalVariable(List <UInt32> usedBranches, UInt32 id)
 {
     if (usedBranches.Contains(this.BranchId))
     {
         return(null);
     }
     if (_iconList != null)
     {
         foreach (ComponentIcon ci in _iconList)
         {
             ComponentIconLocal cil = ci as ComponentIconLocal;
             if (cil != null && cil.LocalPointer != null)
             {
                 if (cil.LocalPointer.MemberId == id)
                 {
                     return(cil.LocalPointer);
                 }
             }
         }
     }
     return(base.GetLocalVariable(usedBranches, id));
 }
 public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
 {
     if (context != null && context.Instance != null && provider != null)
     {
         ActionClass act = context.Instance as ActionClass;
         if (act == null)
         {
             LimnorDesigner.PropertiesWrapper pw = context.Instance as LimnorDesigner.PropertiesWrapper;
             if (pw != null)
             {
                 LimnorDesigner.Action.AB_SingleAction abs = pw.Owner as LimnorDesigner.Action.AB_SingleAction;
                 if (abs != null)
                 {
                     act = abs.ActionData as ActionClass;
                 }
             }
         }
         if (act != null && act.ScopeMethod != null)
         {
             MethodClass mc = act.ScopeMethod as MethodClass;
             if (mc != null && (mc.CurrentEditor != null || mc.CurrentSubEditor != null))
             {
                 IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
                 if (edSvc != null)
                 {
                     listAssignedTo list = new listAssignedTo(edSvc);
                     edSvc.DropDownControl(list);
                     if (list.SelectedAssignedTo == 0)
                     {
                         ComponentIconLocal cil       = null;
                         MethodClass        actMethod = act.ActionMethod as MethodClass;
                         if (actMethod == null)
                         {
                             CustomMethodPointer cmp = act.ActionMethod as CustomMethodPointer;
                             if (cmp != null)
                             {
                                 actMethod = cmp.MethodDef;
                             }
                         }
                         if (act.ReturnValueType.IsLibType)
                         {
                             Type t = act.ReturnValueType.BaseClassType;
                             if (t.IsArray)
                             {
                                 ArrayPointer ap = new ArrayPointer(new TypePointer(t.GetElementType()));
                                 if (mc.CurrentSubEditor != null)
                                 {
                                     cil = mc.CurrentSubEditor.CreateLocalVariable(ap, new System.Drawing.Point(0, 0), actMethod, false);
                                 }
                                 else
                                 {
                                     cil = mc.CurrentEditor.CreateLocalVariable(ap, new System.Drawing.Point(0, 0), actMethod, false);
                                 }
                             }
                         }
                         if (cil == null)
                         {
                             if (mc.CurrentSubEditor != null)
                             {
                                 cil = mc.CurrentSubEditor.CreateLocalVariable(act.ReturnValueType, new System.Drawing.Point(0, 0), actMethod, false);
                             }
                             else
                             {
                                 cil = mc.CurrentEditor.CreateLocalVariable(act.ReturnValueType, new System.Drawing.Point(0, 0), actMethod, false);
                             }
                         }
                         cil.LocalPointer.Owner = mc;
                         if (cil.LocalPointer.BaseClassType.IsGenericParameter)
                         {
                             if (cil.LocalPointer.ClassType.ConcreteType == null)
                             {
                                 DataTypePointer dp = act.GetConcreteType(cil.LocalPointer.BaseClassType);
                                 if (dp != null)
                                 {
                                     cil.LocalPointer.ClassType.SetConcreteType(dp);
                                 }
                             }
                         }
                         else if (cil.LocalPointer.BaseClassType.IsGenericType)
                         {
                             MethodPointer mp = act.ActionMethod as MethodPointer;
                             if (mp != null)
                             {
                                 if (mp.ReturnTypeConcrete != null)
                                 {
                                     cil.LocalPointer.SetDataType(mp.ReturnTypeConcrete);
                                 }
                                 else
                                 {
                                     DataTypePointer dp = mp.GetConcreteType(cil.LocalPointer.BaseClassType);
                                     if (dp != null)
                                     {
                                         cil.LocalPointer.SetDataType(dp);
                                     }
                                 }
                             }
                         }
                         value = cil.LocalPointer;
                     }
                     else if (list.SelectedAssignedTo == 1)
                     {
                         LValueSelector pe = new LValueSelector();
                         value = pe.EditValue(context, provider, value);
                     }
                 }
             }
         }
     }
     return(value);
 }
        public void RemoveLocalVariable(ComponentIconLocal v)
        {
            List <UInt32> usedBranches = new List <uint>();

            this.RemoveLocalVariable(v, usedBranches);
        }
        public override bool OnExportCode(ActionBranch previousAction, ActionBranch nextAction, ILimnorCodeCompiler compiler, CodeMemberMethod method, CodeStatementCollection statements)
        {
            CodeExpression c;

            if (_logicExpression == null)
            {
                c = new CodePrimitiveExpression(true);
            }
            else
            {
                _logicExpression.PrepareForCompile(this.Method);
                c = _logicExpression.ExportCode(this.Method);
            }
            CodeIterationStatement cis = new CodeIterationStatement();

            cis.TestExpression = c;
            if (_initAction != null && _initAction.Action != null)
            {
                CodeStatementCollection sts = new CodeStatementCollection();
                _initAction.Action.ExportCode(null, null, compiler, Method, method, sts, false);
                if (sts.Count > 0)
                {
                    for (int i = 0; i < sts.Count; i++)
                    {
                        if (!(sts[i] is CodeCommentStatement))
                        {
                            cis.InitStatement = sts[i];
                            break;
                        }
                    }
                }
                else
                {
                    cis.InitStatement = new CodeSnippetStatement();
                }
            }
            else
            {
                cis.InitStatement = new CodeSnippetStatement();
            }
            if (_increAction != null && _increAction.Action != null)
            {
                CodeStatementCollection sts = new CodeStatementCollection();
                _increAction.Action.ExportCode(null, null, compiler, Method, method, sts, false);
                if (sts.Count > 0)
                {
                    for (int i = 0; i < sts.Count; i++)
                    {
                        if (!(sts[i] is CodeCommentStatement))
                        {
                            cis.IncrementStatement = sts[i];
                            break;
                        }
                    }
                }
                else
                {
                    cis.IncrementStatement = new CodeSnippetStatement();
                }
            }
            else
            {
                cis.IncrementStatement = new CodeSnippetStatement();
            }
            statements.Add(cis);
            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);
                    }
                }
            }
            Method.SubMethod.Push(this);
            CompilerUtil.AddSubMethod(method, this);
            bool bRet = base.OnExportCode(previousAction, nextAction, compiler, method, cis.Statements);

            Method.SubMethod.Pop();
            bRet = CompilerUtil.FinishSubMethod(method, this, cis.Statements, bRet);
            return(bRet);
        }
        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);
        }
示例#10
0
 public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
 {
     if (context != null && context.Instance != null && provider != null)
     {
         IWindowsFormsEditorService service = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
         if (service != null)
         {
             DataTypePointer  typeScope = null;
             ITypeScopeHolder th        = context.Instance as ITypeScopeHolder;
             if (th != null)
             {
                 typeScope = th.GetTypeScope(context.PropertyDescriptor.Name);
             }
             if (typeScope == null)
             {
                 foreach (Attribute a in context.PropertyDescriptor.Attributes)
                 {
                     TypeScopeAttribute ts = a as TypeScopeAttribute;
                     if (ts != null && ts.Scope != null)
                     {
                         if (ts.Scope.IsGenericParameter)
                         {
                             Type[] ctps = ts.Scope.GetGenericParameterConstraints();
                             if (ctps != null && ctps.Length > 0)
                             {
                                 typeScope = new DataTypePointer(new TypePointer(ctps[0]));
                                 break;
                             }
                         }
                         else
                         {
                             typeScope = new DataTypePointer(new TypePointer(ts.Scope));
                             break;
                         }
                     }
                 }
             }
             MethodClass        scopeMethod = null;
             IScopeMethodHolder mh          = context.Instance as IScopeMethodHolder;
             if (mh != null)
             {
                 scopeMethod = mh.GetScopeMethod();
             }
             IWithProject mc = context.Instance as IWithProject;
             if (mc == null)
             {
                 ComponentInterfaceWrapper ciw = context.Instance as ComponentInterfaceWrapper;
                 if (ciw != null)
                 {
                     mc = ciw.Value as IWithProject;
                 }
             }
             if (mc == null)
             {
                 MathNode.Log(TraceLogClass.GetForm(provider), new DesignerException("{0} does not implement IWithProject", context.Instance.GetType()));
             }
             else
             {
                 if (mc.Project == null)
                 {
                     MathNode.Log(TraceLogClass.GetForm(provider), new DesignerException("Project not set for {0} [{1}]", mc, mc.GetType()));
                 }
                 else
                 {
                     MethodDiagramViewer mdv = mc as MethodDiagramViewer;
                     if (mdv != null)
                     {
                         WebClientEventHandlerMethod wcehm = mdv.Method as WebClientEventHandlerMethod;
                         if (wcehm != null)
                         {
                             if (string.CompareOrdinal("ReturnType", context.PropertyDescriptor.Name) == 0)
                             {
                                 return(value);
                             }
                         }
                     }
                     bool            isMethodReturn = false;
                     IObjectPointer  op             = value as IObjectPointer;
                     DataTypePointer val            = new DataTypePointer();
                     if (op != null)
                     {
                         val.SetDataType(op);
                     }
                     for (int i = 0; i < context.PropertyDescriptor.Attributes.Count; i++)
                     {
                         MethodReturnAttribute mra = context.PropertyDescriptor.Attributes[i] as MethodReturnAttribute;
                         if (mra != null)
                         {
                             isMethodReturn = true;
                             break;
                         }
                     }
                     //
                     bool                   bUseDropDown = false;
                     EnumWebRunAt           runAt        = EnumWebRunAt.Inherit;
                     PropertyClassWebClient pcwc         = context.Instance as PropertyClassWebClient;
                     if (pcwc != null)
                     {
                         bUseDropDown = true;
                         runAt        = EnumWebRunAt.Client;
                     }
                     else
                     {
                         PropertyClassWebServer pcws = context.Instance as PropertyClassWebServer;
                         if (pcws != null)
                         {
                             bUseDropDown = true;
                             runAt        = EnumWebRunAt.Server;
                         }
                     }
                     if (!bUseDropDown)
                     {
                         ParameterClass pc = context.Instance as ParameterClass;
                         if (pc != null)
                         {
                             ConstructorClass cc = pc.Method as ConstructorClass;
                             if (cc != null)
                             {
                                 ClassPointer cp = cc.Owner as ClassPointer;
                                 if (cp != null)
                                 {
                                     if (typeof(Attribute).IsAssignableFrom(cp.BaseClassType))
                                     {
                                         //use drop down
                                         bUseDropDown = true;
                                     }
                                 }
                             }
                         }
                     }
                     //
                     if (bUseDropDown)
                     {
                         TypeSelector drp = TypeSelector.GetAttributeParameterDialogue(service, runAt, val.BaseClassType);
                         service.DropDownControl(drp);
                         if (drp.SelectedType != null)
                         {
                             val.SetDataType(drp.SelectedType);
                             bool bIsForLocalType = false;
                             if (string.Compare(context.PropertyDescriptor.Name, ActionAssignInstance.Instance_Type, StringComparison.Ordinal) == 0)
                             {
                                 PropertiesWrapper pw = context.Instance as PropertiesWrapper;
                                 if (pw != null)
                                 {
                                     AB_SingleAction sa = pw.Owner as AB_SingleAction;
                                     if (sa != null)
                                     {
                                         ActionAssignInstance aa = sa.ActionData as ActionAssignInstance;
                                         if (aa != null)
                                         {
                                             bIsForLocalType = true;
                                             aa.SetParameterValue(ConstObjectPointer.VALUE_Type, drp.SelectedType);
                                         }
                                     }
                                 }
                             }
                             if (bIsForLocalType)
                             {
                             }
                             else
                             {
                                 value = val;
                             }
                         }
                     }
                     else
                     {
                         Type        typeAttr = null;
                         MethodClass mc0      = scopeMethod;
                         if (mc0 == null)
                         {
                             mc0 = mc as MethodClass;
                         }
                         if (mc0 == null)
                         {
                             MethodDiagramViewer mcv = mc as MethodDiagramViewer;
                             if (mcv != null)
                             {
                                 mc0 = mcv.Method;
                             }
                         }
                         if (mc0 != null)
                         {
                             if (mc.Project.ProjectType == EnumProjectType.WebAppPhp)
                             {
                                 if (mc0.WebUsage == EnumMethodWebUsage.Server)
                                 {
                                     typeAttr = typeof(PhpTypeAttribute);
                                 }
                                 else
                                 {
                                     typeAttr = typeof(JsTypeAttribute);
                                 }
                             }
                             else if (mc.Project.ProjectType == EnumProjectType.WebAppAspx)
                             {
                                 if (mc0.WebUsage == EnumMethodWebUsage.Client)
                                 {
                                     typeAttr = typeof(JsTypeAttribute);
                                 }
                             }
                         }
                         FrmObjectExplorer dlg = DesignUtil.GetDataTypeSelectionDialogue(mc.Project, scopeMethod, val, isMethodReturn, typeScope, typeAttr);
                         if (service.ShowDialog(dlg) == DialogResult.OK)
                         {
                             val.SetDataType(dlg.SelectedDataType);
                             bool bIsForLocalType = false;
                             if (string.Compare(context.PropertyDescriptor.Name, ActionAssignInstance.Instance_Type, StringComparison.Ordinal) == 0)
                             {
                                 PropertiesWrapper pw = context.Instance as PropertiesWrapper;
                                 if (pw != null)
                                 {
                                     AB_SingleAction sa = pw.Owner as AB_SingleAction;
                                     if (sa != null)
                                     {
                                         ActionAssignInstance aa = sa.ActionData as ActionAssignInstance;
                                         if (aa != null)
                                         {
                                             bIsForLocalType = true;
                                             aa.SetParameterValue(ActionAssignInstance.Instance_Type, dlg.SelectedDataType);
                                         }
                                     }
                                 }
                             }
                             else
                             {
                                 ComponentIconLocal cil = context.Instance as ComponentIconLocal;
                                 bIsForLocalType = (cil != null);
                                 if (bIsForLocalType)
                                 {
                                     cil.LocalPointer.ClassType = dlg.SelectedDataType;
                                 }
                             }
                             if (bIsForLocalType)
                             {
                             }
                             else
                             {
                                 ExceptionHandlerList.PropertyDescriptorExceptionHandler pdeh = context.PropertyDescriptor as ExceptionHandlerList.PropertyDescriptorExceptionHandler;
                                 if (pdeh != null)
                                 {
                                     pdeh.Handler.ExceptionType = val;
                                 }
                                 else
                                 {
                                     value = val;
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     return(value);
 }
        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);
        }