public void Visit(ProcedureCall call) { var domArg = new CodeDomArg(); CodeMemberMethod method = new CodeMemberMethod(); method.Name = "Exec_" + domArg.MethodIdentifier; method.Attributes = MemberAttributes.Private; GenerateCallStatement(method.Statements, call.Line.Line); _mainType.Type.Members.Add(method); var methodStatements = new CodeStatementCollection(); var argList = new List<CodeExpression>(); foreach(var arg in call.Args) { domArg = VisitChild(arg); argList.Add(domArg.CodeExpression); } methodStatements.Add( new CodeVariableDeclarationStatement(call.Name, "r", new CodeObjectCreateExpression(call.Name, argList.ToArray())) ); methodStatements.Add( new CodeAssignStatement( new CodePropertyReferenceExpression(new CodeVariableReferenceExpression("r"), "RequestFactory"), new CodePropertyReferenceExpression(null, "RequestFactory")) ); var delegateGen = new CodeDelegateCreateExpression(new CodeTypeReference(typeof(Action<ProgressArgs>)), new CodeThisReferenceExpression(), "OnProgress"); methodStatements.Add(new CodeAttachEventStatement(new CodeVariableReferenceExpression("r"), "Progress", delegateGen)); methodStatements.Add( new CodeMethodInvokeExpression(new CodeVariableReferenceExpression("r"), "Run") ); methodStatements.Add(new CodeRemoveEventStatement(new CodeVariableReferenceExpression("r"), "Progress", delegateGen)); method.Statements.AddRange(methodStatements); var methodcall = new CodeMethodInvokeExpression( new CodeMethodReferenceExpression(null, method.Name)); _codeStack.Peek().ParentStatements.Add(methodcall); }
public void Visit(ProcedureCall call, CommonTree tree) { Parent(tree).Children.Add(call); SetLine(call, tree); call.Name = tree.Children[0].Text; for(int x = 1; x < tree.ChildCount; x++) Visit(tree.Children[x]); }