コード例 #1
0
        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);
                }
            }
        }
コード例 #2
0
ファイル: CodeGenerator.cs プロジェクト: polytronicgr/pytocs
 public string EscapeKeywordName(string name)
 {
     return(IndentingTextWriter.NameNeedsQuoting(name)
         ? "@" + name
         : name);
 }
コード例 #3
0
 public CSharpExpressionWriter(IndentingTextWriter writer)
 {
     this.writer     = writer;
     this.precedence = PrecBase;
 }
コード例 #4
0
 public CSharpStatementWriter(IndentingTextWriter writer)
 {
     this.writer    = writer;
     this.expWriter = new CSharpExpressionWriter(writer);
 }
コード例 #5
0
 public CSharpTypeWriter(CodeTypeDeclaration?type, IndentingTextWriter writer)
 {
     this.type      = type;
     this.writer    = writer;
     this.expWriter = new CSharpExpressionWriter(writer);
 }
コード例 #6
0
 public void GenerateCodeFromStatement(CodeStatement csStmt, TextWriter writer, CodeGeneratorOptions codeGeneratorOptions)
 {
     this.writer = new IndentingTextWriter(writer);
     stmWriter   = new CSharpStatementWriter(this.writer);
     csStmt.Accept(stmWriter);
 }
コード例 #7
0
 public void GenerateCodeFromType(CodeTypeDeclaration type, TextWriter writer, CodeGeneratorOptions codeGeneratorOptions)
 {
     this.writer     = new IndentingTextWriter(writer);
     this.typeWriter = new CSharpTypeWriter(type, this.writer);
     type.Accept(typeWriter);
 }
コード例 #8
0
 public void GenerateCodeFromExpression(CodeExpression csExp, TextWriter writer, CodeGeneratorOptions codeGeneratorOptions)
 {
     this.writer = new IndentingTextWriter(writer);
     csExp.Accept(new CSharpExpressionWriter(this.writer));
 }
コード例 #9
0
 public CSharpUnitWriter(CSharpCodeProvider pvd, IndentingTextWriter indentingTextWriter)
 {
     this.pvd    = pvd;
     this.writer = indentingTextWriter;
 }
コード例 #10
0
 public CSharpUnitWriter(IndentingTextWriter indentingTextWriter)
 {
     this.writer = indentingTextWriter;
 }
コード例 #11
0
 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(")");
 }