jtr/DevDisciples.Json.Tools/JsonFormatter.Context.cs
2024-09-15 17:23:27 +02:00

20 lines
677 B
C#

using System.Text;
namespace DevDisciples.Json.Tools;
public static partial class JsonFormatter
{
public class Context
{
protected int Depth { get; set; } = 0;
public StringBuilder Builder { get; set; } = new();
public bool Beautify { get; set; } = false;
public string Indent => new(' ', Depth);
public int IndentSize { get; set; } = 2;
public string NewLine => Beautify ? "\n" : "";
public string Space => Beautify ? " " : "";
public void IncrementDepth() => Depth += Beautify ? IndentSize : 0;
public void DecrementDepth() => Depth -= Beautify ? IndentSize : 0;
}
}