public override object VisitWithStatement(WithStatement withStatement, object data) { withStatementCount++; string varName = "_with" + withStatementCount; WithConvertVisitor converter = new WithConvertVisitor(varName); LocalVariableDeclaration withVariable = new LocalVariableDeclaration(new VariableDeclaration(varName, withStatement.Expression, new TypeReference("var", true))); withStatement.Body.AcceptVisitor(converter, null); base.VisitWithStatement(withStatement, data); var statements = withStatement.Body.Children; statements.Insert(0, withVariable); withVariable.Parent = withStatement.Body; statements.Reverse(); foreach (var stmt in statements) { InsertAfterSibling(withStatement, stmt); } RemoveCurrentNode(); return(null); }
public override object VisitWithStatement(WithStatement withStatement, object data) { withStatementCount++; string varName = "_with" + withStatementCount; WithConvertVisitor converter = new WithConvertVisitor(varName); LocalVariableDeclaration withVariable = new LocalVariableDeclaration(new VariableDeclaration(varName, withStatement.Expression, new TypeReference("var", true))); withStatement.Body.AcceptVisitor(converter, null); base.VisitWithStatement(withStatement, data); var statements = withStatement.Body.Children; statements.Insert(0, withVariable); withVariable.Parent = withStatement.Body; statements.Reverse(); foreach (var stmt in statements) { InsertAfterSibling(withStatement, stmt); } RemoveCurrentNode(); return null; }