public static void WriteParameter(CodeParameterDeclarationExpression param, IndentingTextWriter writer) { var expType = new CSharpExpressionWriter(writer); if (param.IsVarargs) { writer.Write("params"); writer.Write(" "); writer.Write("object"); writer.Write(" [] "); writer.WriteName(param.ParameterName !); } else { expType.VisitTypeReference(param.ParameterType !); writer.Write(" "); writer.WriteName(param.ParameterName !); if (param.DefaultValue != null) { writer.Write(" = "); param.DefaultValue.Accept(expType); } } }
public string EscapeKeywordName(string name) { return(IndentingTextWriter.NameNeedsQuoting(name) ? "@" + name : name); }
public CSharpExpressionWriter(IndentingTextWriter writer) { this.writer = writer; this.precedence = PrecBase; }
public CSharpStatementWriter(IndentingTextWriter writer) { this.writer = writer; this.expWriter = new CSharpExpressionWriter(writer); }
public CSharpTypeWriter(CodeTypeDeclaration?type, IndentingTextWriter writer) { this.type = type; this.writer = writer; this.expWriter = new CSharpExpressionWriter(writer); }
public void GenerateCodeFromStatement(CodeStatement csStmt, TextWriter writer, CodeGeneratorOptions codeGeneratorOptions) { this.writer = new IndentingTextWriter(writer); stmWriter = new CSharpStatementWriter(this.writer); csStmt.Accept(stmWriter); }
public void GenerateCodeFromType(CodeTypeDeclaration type, TextWriter writer, CodeGeneratorOptions codeGeneratorOptions) { this.writer = new IndentingTextWriter(writer); this.typeWriter = new CSharpTypeWriter(type, this.writer); type.Accept(typeWriter); }
public void GenerateCodeFromExpression(CodeExpression csExp, TextWriter writer, CodeGeneratorOptions codeGeneratorOptions) { this.writer = new IndentingTextWriter(writer); csExp.Accept(new CSharpExpressionWriter(this.writer)); }
public CSharpUnitWriter(CSharpCodeProvider pvd, IndentingTextWriter indentingTextWriter) { this.pvd = pvd; this.writer = indentingTextWriter; }
public CSharpUnitWriter(IndentingTextWriter indentingTextWriter) { this.writer = indentingTextWriter; }
public static void WriteMethodParameters(List <CodeParameterDeclarationExpression> parameters, IndentingTextWriter writer) { writer.Write("("); if (parameters.Count > 4) { // Poor man's pretty printer ++writer.IndentLevel; writer.WriteLine(); for (int i = 0; i < parameters.Count; ++i) { WriteParameter(parameters[i], writer); if (i < parameters.Count - 1) { writer.WriteLine(","); } } --writer.IndentLevel; } else { var sep = ""; foreach (var param in parameters) { writer.Write(sep); sep = ", "; WriteParameter(param, writer); } } writer.WriteName(")"); }