wabbajack/Wabbajack.DTOs.ConverterGenerators/CFile.cs
2021-10-23 10:51:17 -06:00

39 lines
900 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++;
}
}