public void Catch(string errorName, Action <TSBlock> catchAction) { builder.Line($" catch ({errorName}) {{"); builder.Indent(() => { using (TSBlock block = new TSBlock(builder)) { catchAction.Invoke(block); } }); builder.Text($"}}"); }
public void Else(Action <TSBlock> bodyAction) { builder.Line($" else {{"); builder.Indent(() => { using (TSBlock block = new TSBlock(builder)) { bodyAction.Invoke(block); } }); builder.Text($"}}"); }
public TSTryBlock Try(Action <TSBlock> tryAction) { Line($"try {{"); Indent(() => { using (TSBlock block = new TSBlock(this)) { tryAction.Invoke(block); } }); Text($"}}"); return(new TSTryBlock(this)); }
public TSIfBlock If(string condition, Action <TSBlock> bodyAction) { Line($"if ({condition}) {{"); Indent(() => { using (TSBlock block = new TSBlock(this)) { bodyAction.Invoke(block); } }); Text($"}}"); return(new TSIfBlock(this)); }
public TSIfBlock ElseIf(string condition, Action <TSBlock> bodyAction) { builder.Line($" else if ({condition}) {{"); builder.Indent(() => { using (TSBlock block = new TSBlock(builder)) { bodyAction.Invoke(block); } }); builder.Text($"}}"); return(new TSIfBlock(builder)); }
public void Block(string beforeBlock, bool newLineAfterBlock, Action <TSBlock> blockAction) { Line($"{beforeBlock} {{"); Indent(() => { using (TSBlock block = new TSBlock(this)) { blockAction.Invoke(block); } }); WriteNewLineBeforeNextText = true; Text($"}}"); WriteNewLineBeforeNextText = newLineAfterBlock; }
public TSTryBlock Try(Action <TSBlock> tryAction) { Line($"try {{"); Indent(() => { using (TSBlock block = new TSBlock(this)) { tryAction.Invoke(block); } }); if (CurrentState == State.LineWithText) { Line(); } Text($"}}"); return(new TSTryBlock(this)); }