2022-10-30 14:49:22 +00:00
|
|
|
|
namespace Processor.Generators;
|
|
|
|
|
|
|
|
|
|
public static class Generator
|
|
|
|
|
{
|
|
|
|
|
private static readonly Dictionary<Type, IGenerator> GENERATORS = new();
|
|
|
|
|
private static readonly IGenerator VOID_GENERATOR = new VoidGenerator();
|
|
|
|
|
|
|
|
|
|
public static IGenerator Get(Type genType) => genType switch
|
|
|
|
|
{
|
2023-02-13 19:47:22 +00:00
|
|
|
|
Type.DOTNET => GENERATORS.TryGetValue(genType, out var value) ? value : GENERATORS[genType] = new DotnetBigFile(),
|
|
|
|
|
Type.GODOT => GENERATORS.TryGetValue(genType, out var value) ? value : GENERATORS[genType] = new GodotCSV(),
|
2022-10-30 14:49:22 +00:00
|
|
|
|
|
|
|
|
|
_ => VOID_GENERATOR,
|
|
|
|
|
};
|
|
|
|
|
|
2022-11-01 18:24:27 +00:00
|
|
|
|
public static async Task<ProcessorResult<long>> TriggerAllAsync()
|
2022-10-30 14:49:22 +00:00
|
|
|
|
{
|
2022-11-01 18:24:27 +00:00
|
|
|
|
long bytesWritten = 0;
|
2023-02-13 19:47:22 +00:00
|
|
|
|
if (await AppSettings.GetGeneratorDotnetEnabled())
|
2022-11-01 18:24:27 +00:00
|
|
|
|
{
|
|
|
|
|
var result = await Generator.Get(Type.DOTNET).GenerateAsync();
|
|
|
|
|
if(!result.Successful)
|
|
|
|
|
return result;
|
|
|
|
|
|
|
|
|
|
bytesWritten += result.Result;
|
|
|
|
|
}
|
|
|
|
|
|
2023-02-13 19:47:22 +00:00
|
|
|
|
if(await AppSettings.GetGeneratorGodotEnabled())
|
2022-11-01 18:24:27 +00:00
|
|
|
|
{
|
|
|
|
|
var result = await Generator.Get(Type.GODOT).GenerateAsync();
|
|
|
|
|
if(!result.Successful)
|
|
|
|
|
return result;
|
|
|
|
|
|
|
|
|
|
bytesWritten += result.Result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return new ProcessorResult<long>(bytesWritten);
|
2022-10-30 14:49:22 +00:00
|
|
|
|
}
|
|
|
|
|
}
|