jtr/Jtr.Tools/JsonFormatter.Context.cs
mdnapo 96c203f842
All checks were successful
Run the JSON parser tests / test (push) Has been skipped
Moved UI to separate project, added Dockerfile & renamed project
2024-10-19 12:04:40 +02:00

22 lines
735 B
C#

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