TidyUp
is a class that allows you to use a using
statement, to ensure that something is done when it goes out of scope. It makes it obvious what the "end" type action is for a "start" type action, puts both actions next to each other and ensures that the end action gets called.
This code has a minor quality issue, in that the indentLevel++
statement could be a long way away from the indentLevel--
statement, and one could get updated without the other.
public class ObjectWriter
{
int indentLevel;
public void WriteRootObject(SomeClass someClass)