35 lines
981 B
C#
35 lines
981 B
C#
using System.IO;
|
|
using System.Text.Json;
|
|
using System.Text.Json.Serialization;
|
|
|
|
namespace ParadoxSaveParser.WebAPI;
|
|
|
|
public enum SaveFileProcessingStatus
|
|
{
|
|
Initialized, Uploading, Uploaded, Parsing, SavingResults, Done, Error
|
|
}
|
|
|
|
public enum Game
|
|
{
|
|
Unknown, EU4
|
|
}
|
|
|
|
public class SaveFileMetadata
|
|
{
|
|
public required string id { get; init; }
|
|
|
|
[JsonConverter(typeof(JsonStringEnumConverter))]
|
|
public required Game game { get; init; }
|
|
|
|
[JsonConverter(typeof(JsonStringEnumConverter))]
|
|
public required SaveFileProcessingStatus status { get; set; }
|
|
|
|
public string? errorMesage { get; set; }
|
|
|
|
private static readonly JsonSerializerOptions _jsonOptions = new() { WriteIndented = true };
|
|
public void SaveToFile()
|
|
{
|
|
using var metaFile = File.Open(PathHelper.GetMetaFilePath(id), FileMode.CreateNew, FileAccess.Write);
|
|
JsonSerializer.Serialize(metaFile, this, _jsonOptions);
|
|
}
|
|
} |