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


C# StatementSyntax.GetType方法代码示例

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


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

示例1: FlattenStatement

        public void FlattenStatement(StatementSyntax ss, List<FlatStatement> instructions)
        {
            switch (ss.Kind)
            {
                case SyntaxKind.Block:
                    Flatten((BlockSyntax)ss,instructions);
                    return;
                case SyntaxKind.ExpressionStatement:
                    Flatten((ExpressionStatementSyntax)ss,instructions);
                    return;
                case SyntaxKind.ReturnStatement:
                    Flatten((ReturnStatementSyntax)ss,instructions);
                    return;
                case SyntaxKind.LocalDeclarationStatement:
                    Flatten((LocalDeclarationStatementSyntax)ss,instructions);
                    return;
                case SyntaxKind.ForStatement:
                    Flatten((ForStatementSyntax)ss,instructions);
                    return;
                case SyntaxKind.IfStatement:
                    Flatten((IfStatementSyntax)ss,instructions);
                    return;
                case SyntaxKind.BreakStatement:
                    Flatten((BreakStatementSyntax)ss,instructions);
                    return;
                case SyntaxKind.ContinueStatement:
                    Flatten((ContinueStatementSyntax)ss, instructions);
                    return;
                case SyntaxKind.TryStatement:
                    Flatten((TryStatementSyntax)ss,instructions);
                    return;
                case SyntaxKind.DoStatement:
                    Flatten((DoStatementSyntax)ss,instructions);
                    return;
                case SyntaxKind.WhileStatement:
                    Flatten((WhileStatementSyntax)ss,instructions);
                    return;
                case SyntaxKind.EmptyStatement:
                    // do nothing. :)
                    return;
                case SyntaxKind.SwitchStatement:
                    Flatten((SwitchStatementSyntax)ss,instructions);
                    return;
                case SyntaxKind.ThrowStatement:
                    Flatten((ThrowStatementSyntax)ss,instructions);
                    return;
                case SyntaxKind.ForEachStatement:
                    Flatten((ForEachStatementSyntax)ss,instructions);
                    return;
                case SyntaxKind.LockStatement:
                    Flatten((LockStatementSyntax)ss, instructions);
                    return;
                case SyntaxKind.UsingStatement:
                    Flatten((UsingStatementSyntax)ss, instructions);
                    return;
                case SyntaxKind.GotoStatement:
                case SyntaxKind.GotoCaseStatement:
                case SyntaxKind.GotoDefaultStatement:
                    Flatten((GotoStatementSyntax)ss, instructions);
                    return;

                case SyntaxKind.CheckedStatement:
                case SyntaxKind.FixedStatement:
                case SyntaxKind.GlobalStatement:
                case SyntaxKind.LabeledStatement:

                case SyntaxKind.UncheckedStatement:
                case SyntaxKind.UnsafeStatement:
                case SyntaxKind.YieldBreakStatement:
                case SyntaxKind.YieldReturnStatement:
                    throw new NotImplementedException("statement type " + ss.GetType().ToString() + ": " + ss.Kind.ToString());
                    break;
                default:
                    throw new NotImplementedException("statement type " + ss.GetType().ToString() + ": " + ss.Kind.ToString());
                    break;
            }
        }
开发者ID:VendanAndrews,项目名称:ls2csc,代码行数:77,代码来源:Function.cs

示例2: CompileStatement

 protected virtual void CompileStatement(StatementSyntax statement)
 {
     if      (statement is IfStatementSyntax)               CompileIfStatement(              (IfStatementSyntax)              statement);
     else if (statement is LocalDeclarationStatementSyntax) CompileLocalDeclarationStatement((LocalDeclarationStatementSyntax)statement);
     else if (statement is BlockSyntax)                     CompileBlock(                    (BlockSyntax)                    statement);
     else if (statement is ExpressionStatementSyntax)       CompileExpressionStatement(      (ExpressionStatementSyntax)      statement);
     else if (statement is ReturnStatementSyntax)           CompileReturnStatement(          (ReturnStatementSyntax)          statement);
     else if (statement is ThrowStatementSyntax)            CompileThrowStatement(           (ThrowStatementSyntax)           statement);
     else if (statement is StatementSyntax)                 WriteLine("statement {0}", statement.GetType());
 }
开发者ID:JohnFNovak,项目名称:FragSharp,代码行数:10,代码来源:AbstractCodeWriter.cs


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