wabbajack/Wabbajack.DTOs.ConverterGenerators/CFile.cs
2021-09-27 06:42:46 -06:00

40 lines
1018 B
C#

using System.IO;
using System.Text;
namespace Wabbajack.DTOs.ConverterGenerators
{
public class CFile
{
private readonly StringBuilder _sb;
private int _indent;
public CFile()
{
_sb = new StringBuilder();
Code("// THIS FILE IS AUTOGENERATED DO NOT EDIT BY HAND");
Code("using System;");
Code("using System.Text.Json;");
Code("using System.Text.Json.Serialization;");
Code("using Wabbajack.Hashing.xxHash64;");
Code("using Microsoft.Extensions.DependencyInjection;");
Code("");
}
public void Write(string path)
{
File.WriteAllText(path, _sb.ToString());
}
public void Code(string c)
{
if (c.EndsWith("}"))
_indent--;
for (var i = 0; i < _indent; i++) _sb.Append(" ");
_sb.AppendLine(c);
if (c.EndsWith("{"))
_indent++;
}
}
}