mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
40 lines
1018 B
C#
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++;
|
||
|
}
|
||
|
}
|
||
|
}
|