public override string ToCode(ToCodeFormat format) { StringBuilder sb = new StringBuilder(); // passing a "T" format means nested try's don't actually nest -- they // just add the catch clauses to the end if (format != ToCodeFormat.NestedTry) { sb.Append("try"); if (TryBlock == null) { // empty body sb.Append("{}"); } else { sb.Append(TryBlock.ToCode(ToCodeFormat.NestedTry)); } } else { sb.Append(TryBlock.ToCode(ToCodeFormat.NestedTry)); } // handle the catch clause (if any) // catch should always have braces around it string catchString = ( CatchBlock == null ? string.Empty : CatchBlock.Count == 0 ? "{}" : CatchBlock.ToCode(ToCodeFormat.AlwaysBraces) ); if (catchString.Length > 0) { Parser.Settings.NewLine(sb); sb.Append("catch("); if (m_catchVariable != null) { sb.Append(m_catchVariable.ToString()); } else if (m_catchVarName != null) { sb.Append(m_catchVarName); } sb.Append(')'); sb.Append(catchString); } // handle the finally, if any // finally should always have braces around it string finallyString = ( FinallyBlock == null ? string.Empty : FinallyBlock.ToCode(ToCodeFormat.AlwaysBraces) ); if (finallyString.Length > 0) { Parser.Settings.NewLine(sb); sb.Append("finally"); sb.Append(finallyString); } return(sb.ToString()); }