Mono.CSharp.CSharpCodeGenerator.GenerateTryCatchFinallyStatement C# (CSharp) Method

GenerateTryCatchFinallyStatement() protected method

protected GenerateTryCatchFinallyStatement ( CodeTryCatchFinallyStatement statement ) : void
statement CodeTryCatchFinallyStatement
return void
		protected override void GenerateTryCatchFinallyStatement (CodeTryCatchFinallyStatement statement)
		{
			TextWriter output = Output;
			CodeGeneratorOptions options = Options;

			output.Write ("try");
			OutputStartBrace ();
			++Indent;
			GenerateStatements (statement.TryStatements);
			--Indent;
			
			foreach (CodeCatchClause clause in statement.CatchClauses) {
				output.Write ('}');
				if (options.ElseOnClosing)
					output.Write (' ');
				else
					output.WriteLine ();
				output.Write ("catch (");
				OutputTypeNamePair (clause.CatchExceptionType, GetSafeName(clause.LocalName));
				output.Write (")");
				OutputStartBrace ();
				++Indent;
				GenerateStatements (clause.Statements);
				--Indent;
			}

			CodeStatementCollection finallies = statement.FinallyStatements;
			if (finallies.Count > 0) {
				output.Write ('}');
				if (options.ElseOnClosing)
					output.Write (' ');
				else
					output.WriteLine ();
				output.Write ("finally");
				OutputStartBrace ();
				++Indent;
				GenerateStatements (finallies);
				--Indent;
			}

			output.WriteLine('}');
		}
CSharpCodeGenerator