mirror of https://github.com/Squidex/squidex.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
65 lines
1.5 KiB
65 lines
1.5 KiB
// ==========================================================================
|
|
// Squidex Headless CMS
|
|
// ==========================================================================
|
|
// Copyright (c) Squidex UG (haftungsbeschraenkt)
|
|
// All rights reserved. Licensed under the MIT license.
|
|
// ==========================================================================
|
|
|
|
using System.Text;
|
|
|
|
namespace GenerateLanguages
|
|
{
|
|
internal sealed class SourceBuilder
|
|
{
|
|
private readonly StringBuilder builder = new StringBuilder();
|
|
private int intentation;
|
|
|
|
public SourceBuilder StartBlock()
|
|
{
|
|
intentation += 4;
|
|
|
|
return this;
|
|
}
|
|
|
|
public SourceBuilder WriteLine(string line)
|
|
{
|
|
if (line.Equals("}", StringComparison.Ordinal))
|
|
{
|
|
EndBlock();
|
|
}
|
|
|
|
for (var i = 0; i < intentation; i++)
|
|
{
|
|
builder.Append(' ');
|
|
}
|
|
|
|
builder.AppendLine(line);
|
|
|
|
if (line.Equals("{", StringComparison.Ordinal))
|
|
{
|
|
StartBlock();
|
|
}
|
|
|
|
return this;
|
|
}
|
|
|
|
public SourceBuilder WriteLine()
|
|
{
|
|
builder.AppendLine();
|
|
|
|
return this;
|
|
}
|
|
|
|
public SourceBuilder EndBlock()
|
|
{
|
|
intentation -= 4;
|
|
|
|
return this;
|
|
}
|
|
|
|
public override string ToString()
|
|
{
|
|
return builder.ToString();
|
|
}
|
|
}
|
|
}
|
|
|