All checks were successful
Run the JSON parser tests / test (push) Has been skipped
31 lines
891 B
C#
31 lines
891 B
C#
using Humanizer;
|
|
|
|
namespace Jtr.Tools;
|
|
|
|
public static partial class Json2CSharpTranslator
|
|
{
|
|
public readonly struct ClassTranslation : ITranslation
|
|
{
|
|
public string Name { get; init; }
|
|
public List<PropertyTranslation> Properties { get; init; }
|
|
|
|
public void Translate(Context context)
|
|
{
|
|
|
|
context.Builder.Append($"public class {Name.Pascalize()}\n");
|
|
context.Builder.Append("{\n");
|
|
|
|
if (Properties.Count != 0)
|
|
{
|
|
var last = Properties.Last();
|
|
foreach (var property in Properties)
|
|
{
|
|
property.Translate(context);
|
|
context.Builder.Append(property.Equals(last) ? string.Empty : "\n");
|
|
}
|
|
}
|
|
|
|
context.Builder.Append("}\n\n");
|
|
}
|
|
}
|
|
} |