Microsoft.CSharp.CSharpCodeGenerator.GenerateTryCatchFinallyStatement C# (CSharp) Méthode

GenerateTryCatchFinallyStatement() private méthode

private GenerateTryCatchFinallyStatement ( CodeTryCatchFinallyStatement e ) : void
e CodeTryCatchFinallyStatement
Résultat void
        private void GenerateTryCatchFinallyStatement(CodeTryCatchFinallyStatement e)
        {
            Output.Write("try");
            OutputStartingBrace();
            Indent++;
            GenerateStatements(e.TryStatements);
            Indent--;
            CodeCatchClauseCollection catches = e.CatchClauses;
            if (catches.Count > 0)
            {
                foreach (CodeCatchClause current in catches)
                {
                    Output.Write('}');
                    if (Options.ElseOnClosing)
                    {
                        Output.Write(' ');
                    }
                    else
                    {
                        Output.WriteLine();
                    }
                    Output.Write("catch (");
                    OutputType(current.CatchExceptionType);
                    Output.Write(' ');
                    OutputIdentifier(current.LocalName);
                    Output.Write(')');
                    OutputStartingBrace();
                    Indent++;
                    GenerateStatements(current.Statements);
                    Indent--;
                }
            }

            CodeStatementCollection finallyStatements = e.FinallyStatements;
            if (finallyStatements.Count > 0)
            {
                Output.Write('}');
                if (Options.ElseOnClosing)
                {
                    Output.Write(' ');
                }
                else
                {
                    Output.WriteLine();
                }
                Output.Write("finally");
                OutputStartingBrace();
                Indent++;
                GenerateStatements(finallyStatements);
                Indent--;
            }
            Output.WriteLine('}');
        }
CSharpCodeGenerator