本文整理汇总了C#中IFormatter.WriteIndent方法的典型用法代码示例。如果您正苦于以下问题:C# IFormatter.WriteIndent方法的具体用法?C# IFormatter.WriteIndent怎么用?C# IFormatter.WriteIndent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IFormatter
的用法示例。
在下文中一共展示了IFormatter.WriteIndent方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WriteUsingStatement
private void WriteUsingStatement(IUsingStatement statement, IFormatter formatter)
{
IVariableReference variable = null;
IAssignExpression assignExpression = statement.Expression as IAssignExpression;
if (assignExpression != null)
{
IVariableDeclarationExpression variableDeclarationExpression = assignExpression.Target as IVariableDeclarationExpression;
if (variableDeclarationExpression != null)
{
variable = variableDeclarationExpression.Variable;
}
IVariableReferenceExpression variableReferenceExpression = assignExpression.Target as IVariableReferenceExpression;
if (variableReferenceExpression != null)
{
variable = variableReferenceExpression.Variable;
}
}
this.WriteStatementSeparator(formatter);
// make a comment that Reflector detected this as a using statement
//formatter.Write("{using");
if (variable != null)
{
//formatter.Write(" ");
this.WriteVariableReference(variable, formatter);
}
formatter.Write("}");
formatter.WriteLine();
// and replace this with
// - create obj
// - try ... finally obj.Dispose end
formatter.WriteKeyword("begin");
formatter.WriteLine();
formatter.WriteIndent();
if (variable != null)
{
this.WriteVariableReference(variable, formatter);
formatter.Write(" ");
formatter.WriteKeyword(":=");
formatter.Write(" ");
this.WriteExpression(assignExpression.Expression, formatter);
this.WriteStatementSeparator(formatter);
}
formatter.WriteKeyword("try");
formatter.WriteLine();
formatter.WriteIndent();
if (statement.Body != null)
{
this.WriteBlockStatement(statement.Body, formatter);
}
formatter.WriteLine();
formatter.WriteOutdent();
formatter.WriteKeyword("finally");
formatter.WriteLine();
formatter.WriteIndent();
if (variable != null)
{
this.firstStmt = true;
this.WriteVariableReference(variable, formatter);
formatter.Write(".");
formatter.Write("Dispose");
formatter.WriteLine();
}
else
{
this.firstStmt = true;
this.WriteExpression(statement.Expression);
formatter.Write(".");
formatter.Write("Dispose");
formatter.WriteLine();
}
formatter.WriteOutdent();
formatter.WriteKeyword("end");
formatter.WriteLine();
formatter.WriteOutdent();
formatter.WriteKeyword("end");
}
示例2: WriteWhileStatement
private void WriteWhileStatement(IWhileStatement statement, IFormatter formatter)
{
this.WriteStatementSeparator(formatter);
formatter.WriteKeyword("while");
formatter.Write(" ");
formatter.Write("(");
if (statement.Condition != null)
{
this.WriteExpression(statement.Condition, formatter);
}
else
formatter.WriteLiteral("true");
formatter.Write(")");
formatter.Write(" {");
formatter.WriteLine();
formatter.WriteIndent();
if (statement.Body != null)
{
this.WriteStatement(statement.Body, formatter);
}
formatter.WriteLine();
formatter.WriteOutdent();
formatter.Write("}");
}
示例3: WriteSwitchStatement
private void WriteSwitchStatement(ISwitchStatement statement, IFormatter formatter)
{
this.WriteStatementSeparator(formatter);
formatter.WriteKeyword("switch");
formatter.Write(" (");
this.WriteExpression(statement.Expression, formatter);
formatter.Write(") ");
formatter.Write("{");
formatter.WriteLine();
foreach (ISwitchCase switchCase in statement.Cases)
{
IConditionCase conditionCase = switchCase as IConditionCase;
if (conditionCase != null)
{
this.WriteSwitchCaseCondition(conditionCase.Condition, formatter);
}
IDefaultCase defaultCase = switchCase as IDefaultCase;
if (defaultCase != null)
{
formatter.WriteKeyword("default");
formatter.Write(":");
}
formatter.WriteIndent();
if (switchCase.Body != null)
{
this.WriteStatement(switchCase.Body, formatter);
this.WritePendingOutdent(formatter);
}
else
{
formatter.WriteLine();
}
formatter.WriteOutdent();
}
formatter.WriteKeyword("}");
}
示例4: WriteTryCatchFinallyStatement
private void WriteTryCatchFinallyStatement(ITryCatchFinallyStatement statement, IFormatter formatter)
{
this.WriteStatementSeparator(formatter);
formatter.WriteKeyword("try");
formatter.Write(" {");
formatter.WriteLine();
formatter.WriteIndent();
if (statement.Try != null)
{
this.WriteStatement(statement.Try, formatter);
this.WritePendingOutdent(formatter);
}
else
{
formatter.WriteLine();
}
formatter.WriteOutdent();
formatter.Write("}");
this.firstStmt = true;
foreach (ICatchClause catchClause in statement.CatchClauses)
{
formatter.WriteLine();
formatter.WriteKeyword("catch");
formatter.Write(" (");
formatter.WriteDeclaration(catchClause.Variable.Name);
formatter.Write(")");
formatter.Write(" {");
formatter.WriteLine();
formatter.WriteIndent();
if (catchClause.Condition != null)
{
formatter.Write(" ");
formatter.WriteKeyword("if");
formatter.Write(" ");
this.WriteExpression(catchClause.Condition, formatter);
formatter.Write(" ");
formatter.WriteKeyword("then");
}
if (catchClause.Body != null)
{
this.WriteStatement(catchClause.Body, formatter);
}
else
{
formatter.WriteLine();
}
formatter.WriteOutdent();
formatter.Write("}");
}
if ((statement.Finally != null) && (statement.Finally.Statements.Count > 0))
{
formatter.WriteLine();
formatter.WriteKeyword("finally");
formatter.Write(" {");
formatter.WriteLine();
formatter.WriteIndent();
if (statement.Finally != null)
{
this.WriteStatement(statement.Finally, formatter);
this.WritePendingOutdent(formatter);
}
else
{
formatter.WriteLine();
}
formatter.WriteOutdent();
formatter.Write("}");
}
}
示例5: WriteLockStatement
private void WriteLockStatement(ILockStatement statement, IFormatter formatter)
{
this.WriteStatementSeparator(formatter);
formatter.WriteKeyword("lock");
formatter.Write(" ");
formatter.Write("(");
this.WriteExpression(statement.Expression, formatter);
formatter.Write(")");
formatter.WriteLine();
formatter.WriteKeyword("begin");
formatter.WriteIndent();
if (statement.Body != null)
{
this.WriteStatement(statement.Body, formatter);
}
formatter.WriteLine();
formatter.WriteOutdent();
formatter.WriteKeyword("end");
}
示例6: WriteQueryExpression
private void WriteQueryExpression(IQueryExpression value, IFormatter formatter)
{
formatter.Write("(");
this.WriteFromClause(value.From, formatter);
if ((value.Body.Clauses.Count > 0) || (value.Body.Continuation != null))
{
formatter.WriteLine();
formatter.WriteIndent();
}
else
{
formatter.Write(" ");
}
this.WriteQueryBody(value.Body, formatter);
formatter.Write(")");
if ((value.Body.Clauses.Count > 0) || (value.Body.Continuation != null))
{
formatter.WriteOutdent();
}
}
示例7: WriteForStatement
private void WriteForStatement(IForStatement statement, IFormatter formatter)
{
this.WriteStatementSeparator(formatter);
formatter.WriteKeyword("for");
formatter.Write(" (");
this.forLoop = true;
this.WriteStatement(statement.Initializer, formatter);
formatter.Write("; ");
this.WriteExpression(statement.Condition, formatter);
formatter.Write("; ");
this.WriteStatement(statement.Increment, formatter);
formatter.Write(")");
this.forLoop = false;
formatter.Write(" {");
formatter.WriteLine();
formatter.WriteIndent();
if (statement.Body != null)
{
this.WriteStatement(statement.Body, formatter);
}
formatter.WriteLine();
formatter.WriteOutdent();
formatter.WriteKeyword("}");
}
示例8: WriteLabeledStatement
private void WriteLabeledStatement(ILabeledStatement statement, IFormatter formatter)
{
if (statement.Statement != null)
{
this.WriteStatementSeparator(formatter);
}
formatter.WriteLine();
formatter.WriteOutdent();
this.WriteDeclaration(statement.Name, formatter);
formatter.Write(":");
formatter.WriteLine();
formatter.WriteIndent();
this.firstStmt = true;
if (statement.Statement != null)
{
this.WriteStatement(statement.Statement, formatter);
}
}
示例9: WriteForEachStatement
private void WriteForEachStatement(IForEachStatement value, IFormatter formatter)
{
// TODO statement.Variable declaration needs to be rendered some where
this.WriteStatementSeparator(formatter);
TextFormatter description = new TextFormatter();
this.WriteVariableDeclaration(value.Variable, description);
formatter.WriteLine();
formatter.WriteKeyword("foreach");
formatter.Write(" (");
formatter.WriteReference(value.Variable.Name, description.ToString(), null);
formatter.WriteKeyword(" in ");
this.WriteExpression(value.Expression, formatter);
formatter.Write(") {");
formatter.WriteLine();
formatter.WriteIndent();
if (value.Body != null)
{
this.WriteStatement(value.Body, formatter);
}
formatter.WriteLine();
formatter.WriteOutdent();
formatter.WriteKeyword("}");
}
示例10: WriteFixedStatement
private void WriteFixedStatement(IFixedStatement statement, IFormatter formatter)
{
this.WriteStatementSeparator(formatter);
formatter.WriteKeyword("fixed");
formatter.Write(" ");
formatter.Write("(");
this.WriteVariableDeclaration(statement.Variable, formatter);
formatter.Write(" ");
formatter.WriteKeyword("=");
formatter.Write(" ");
this.WriteExpression(statement.Expression, formatter);
formatter.Write(")");
formatter.WriteLine();
formatter.WriteKeyword("begin");
formatter.WriteLine();
formatter.WriteIndent();
if (statement.Body != null)
{
this.WriteBlockStatement(statement.Body, formatter);
}
formatter.WriteOutdent();
formatter.WriteKeyword("end ");
}
示例11: WriteConditionStatement
private void WriteConditionStatement(IConditionStatement statement, IFormatter formatter)
{
this.WriteStatementSeparator(formatter);
formatter.WriteKeyword("if");
formatter.Write(" ");
if (statement.Condition is IBinaryExpression)
this.WriteExpression(statement.Condition, formatter);
else
{
formatter.Write("(");
this.WriteExpression(statement.Condition, formatter);
formatter.Write(")");
}
formatter.Write(" {");
formatter.WriteLine();
formatter.WriteIndent();
if (statement.Then != null)
this.WriteStatement(statement.Then, formatter);
else
formatter.WriteLine();
formatter.WriteOutdent();
formatter.Write("}");
if ((statement.Else != null) && (statement.Else.Statements.Count > 0))
{
this.WritePendingOutdent(formatter);
formatter.WriteLine();
formatter.WriteKeyword("else");
formatter.Write(" {");
formatter.WriteLine();
formatter.WriteIndent();
if (statement.Else != null)
{
this.WriteStatement(statement.Else, formatter);
this.WritePendingOutdent(formatter);
}
else
{
formatter.WriteLine();
}
formatter.WriteOutdent();
formatter.Write("}");
}
}
示例12: WriteBlockExpression
private void WriteBlockExpression(IBlockExpression expression, IFormatter formatter)
{
formatter.Write("[");
if (expression.Expressions.Count > 16)
{
formatter.WriteLine();
formatter.WriteIndent();
}
for (int i = 0; i < expression.Expressions.Count; i++)
{
if (i != 0)
{
formatter.Write(", ");
if ((i % 16) == 0)
{
formatter.WriteLine();
}
}
this.WriteExpression(expression.Expressions[i], formatter);
}
if (expression.Expressions.Count > 16)
{
formatter.WriteOutdent();
formatter.WriteLine();
}
formatter.Write("]");
}
示例13: WriteAnonymousMethodExpression
private void WriteAnonymousMethodExpression(IAnonymousMethodExpression value, IFormatter formatter)
{
bool parameters = false;
for (int i = 0; i < value.Parameters.Count; i++)
{
if ((value.Parameters[i].Name != null) && (value.Parameters[i].Name.Length > 0))
{
parameters = true;
}
}
formatter.WriteKeyword("function");
formatter.Write("(");
if (parameters)
{
this.WriteParameterDeclarationList(value.Parameters, formatter, this.configuration);
}
formatter.Write(") {");
formatter.WriteLine();
formatter.WriteIndent();
this.WriteBlockStatement(value.Body, formatter);
formatter.WriteOutdent();
formatter.WriteLine();
formatter.Write("}");
}