当前位置: 首页>>代码示例>>C#>>正文


C# IFormatter.WriteOutdent方法代码示例

本文整理汇总了C#中IFormatter.WriteOutdent方法的典型用法代码示例。如果您正苦于以下问题:C# IFormatter.WriteOutdent方法的具体用法?C# IFormatter.WriteOutdent怎么用?C# IFormatter.WriteOutdent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IFormatter的用法示例。


在下文中一共展示了IFormatter.WriteOutdent方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: 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("}");
            }
开发者ID:jorik041,项目名称:JavaScriptLanguage,代码行数:27,代码来源:JavaScriptLanguage.cs

示例2: 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("}");
                }
            }
开发者ID:jorik041,项目名称:JavaScriptLanguage,代码行数:76,代码来源:JavaScriptLanguage.cs

示例3: 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");
            }
开发者ID:jorik041,项目名称:JavaScriptLanguage,代码行数:89,代码来源:JavaScriptLanguage.cs

示例4: 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();
                }
            }
开发者ID:jorik041,项目名称:JavaScriptLanguage,代码行数:25,代码来源:JavaScriptLanguage.cs

示例5: 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("}");
            }
开发者ID:jorik041,项目名称:JavaScriptLanguage,代码行数:42,代码来源:JavaScriptLanguage.cs

示例6: 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");
            }
开发者ID:jorik041,项目名称:JavaScriptLanguage,代码行数:23,代码来源:JavaScriptLanguage.cs

示例7: WritePendingOutdent

 private void WritePendingOutdent(IFormatter formatter)
 {
     if (pendingOutdent > 0)
     {
         formatter.WriteOutdent();
         pendingOutdent = 0;
     }
 }
开发者ID:jorik041,项目名称:JavaScriptLanguage,代码行数:8,代码来源:JavaScriptLanguage.cs

示例8: 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("}");
            }
开发者ID:jorik041,项目名称:JavaScriptLanguage,代码行数:25,代码来源:JavaScriptLanguage.cs

示例9: 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);
     }
 }
开发者ID:jorik041,项目名称:JavaScriptLanguage,代码行数:18,代码来源:JavaScriptLanguage.cs

示例10: 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("}");
            }
开发者ID:jorik041,项目名称:JavaScriptLanguage,代码行数:28,代码来源:JavaScriptLanguage.cs

示例11: 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 ");
            }
开发者ID:jorik041,项目名称:JavaScriptLanguage,代码行数:27,代码来源:JavaScriptLanguage.cs

示例12: 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("}");
                }
            }
开发者ID:jorik041,项目名称:JavaScriptLanguage,代码行数:47,代码来源:JavaScriptLanguage.cs

示例13: 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("]");
            }
开发者ID:jorik041,项目名称:JavaScriptLanguage,代码行数:33,代码来源:JavaScriptLanguage.cs

示例14: 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("}");
            }
开发者ID:jorik041,项目名称:JavaScriptLanguage,代码行数:27,代码来源:JavaScriptLanguage.cs


注:本文中的IFormatter.WriteOutdent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。