/// <summary> /// Appends the script to represent this object to the StringBuilder. /// </summary> /// <param name="builder">The StringBuilder to which the Javascript is appended.</param> /// <param name="options">The options to use when appending JavaScript</param> /// <param name="allowReservedWords"></param> internal protected override void AppendScript(StringBuilder builder, ScriptOptions options, bool allowReservedWords) { if (builder == null) { throw new ArgumentNullException("builder"); } if (_tryBlock == null) { throw new InvalidOperationException(); } builder.Append("try"); _tryBlock.AppendScript(builder, options, allowReservedWords); if (CatchBlock != null) { if (CatchVariable == null) { throw new InvalidOperationException(); } builder.Append("catch("); CatchVariable.AppendScript(builder, options, allowReservedWords); builder.Append(")"); CatchBlock.AppendScript(builder, options, allowReservedWords); } if (FinallyBlock != null) { builder.Append("finally"); FinallyBlock.AppendScript(builder, options, allowReservedWords); } }
public void AppendTo(StringBuilder sb) { sb.Append("try: {"); TryExprs.AppendTo(sb); sb.AppendLine("}"); sb.Append("catch: "); CatchVariable.AppendTo(sb); sb.Append(" {"); CatchExprs.AppendTo(sb); sb.AppendLine("}"); if (FinallyExprs != null) { sb.Append("finally: {"); FinallyExprs.AppendTo(sb); sb.AppendLine("}"); } }