45 lines
1.1 KiB
C#
45 lines
1.1 KiB
C#
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 _configSerializerOptions = new()
|
|
{
|
|
WriteIndented = true,
|
|
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull,
|
|
};
|
|
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, _configSerializerOptions);
|
|
}
|
|
} |