using System.Text.Json.Serialization; namespace ParadoxSaveParser.WebAPI; public enum SaveFileProcessingStatus { Initialized, Uploading, Uploaded, Parsing, SavingResults, Done } public enum Game { Unknown, EU4 } public class SaveFileMetadata { private static readonly JsonSerializerOptions _jsonOptions = new() { WriteIndented = true }; public required string id { get; init; } [JsonConverter(typeof(JsonStringEnumConverter))] public required Game game { get; init; } [JsonConverter(typeof(JsonStringEnumConverter))] public required SaveFileProcessingStatus status { get; set; } // if error occured during parsing, it's message is saved here // status stays the same as when error occured public string? errorMessage { get; set; } public void SaveToFile() { using var metaFile = File.OpenWrite(PathHelper.GetMetaFilePath(id)); JsonSerializer.Serialize(metaFile, this, _jsonOptions); } }