public override bool IsSameObjectRef(IObjectIdentity objectPointer) { ParameterClass p = objectPointer as ParameterClass; if (p == null) { CustomMethodParameterPointer cmpp = objectPointer as CustomMethodParameterPointer; if (cmpp != null) { p = cmpp.Parameter; } } if (p != null) { if (p.ParameterID == this.ParameterID) { return(true); } if (string.CompareOrdinal(p.CodeName, this.CodeName) == 0) { return(true); } } return(false); }
public ParameterValue CreateDefaultParameterValue(int i) { IParameter p = MethodParameterTypes[i]; ParameterValue pv = new ParameterValue(_action); pv.Name = p.Name; pv.ParameterID = p.ParameterID; ParameterClass pc = p as ParameterClass; if (pc != null) { pv.SetDataType(pc); } else { pv.SetDataType(p.ParameterLibType); } pv.SetOwnerAction(_action); pv.ValueType = EnumValueType.Property; CustomMethodParameterPointer cmpp = new CustomMethodParameterPointer(pc); pv.SetValue(cmpp); return(pv); }
public bool IsSameProperty(ISourceValuePointer p) { ParameterClass pc = p as ParameterClass; if (pc != null) { return(pc.ParameterID == this.ParameterID); } else { CustomMethodParameterPointer cmp = p as CustomMethodParameterPointer; if (cmp != null) { if (cmp.Parameter != null) { if (cmp.Parameter.ParameterID == this.ParameterID) { return(true); } } } } return(false); }
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); }