separated classes into files
This commit is contained in:
parent
1fa3e4eb6e
commit
60f24d6907
@ -24,4 +24,6 @@ public abstract class Parser
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public abstract SaveData Parse();
|
||||
}
|
||||
@ -5,4 +5,11 @@ public class ParserEU4 : Parser
|
||||
public ParserEU4(Stream savefile) : base(savefile)
|
||||
{
|
||||
}
|
||||
|
||||
public override SaveData Parse()
|
||||
{
|
||||
var saveData = new SaveData();
|
||||
|
||||
return saveData;
|
||||
}
|
||||
}
|
||||
6
ParadoxSaveParser.Lib/SaveData.cs
Normal file
6
ParadoxSaveParser.Lib/SaveData.cs
Normal file
@ -0,0 +1,6 @@
|
||||
namespace ParadoxSaveParser.Lib;
|
||||
|
||||
public class SaveData
|
||||
{
|
||||
|
||||
}
|
||||
12
ParadoxSaveParser.WebAPI/PathHelper.cs
Normal file
12
ParadoxSaveParser.WebAPI/PathHelper.cs
Normal file
@ -0,0 +1,12 @@
|
||||
using System.IO;
|
||||
|
||||
namespace ParadoxSaveParser.WebAPI;
|
||||
|
||||
public static class PathHelper
|
||||
{
|
||||
|
||||
public const string DATA_DIR = "data";
|
||||
public static string SAVES_DIR = Path.Join(DATA_DIR, "saves");
|
||||
public static string GetMetaFilePath(string save_id) => Path.Join(SAVES_DIR, save_id + ".meta.json");
|
||||
public static string GetEU4SaveFilePath(string save_id) => Path.Join(SAVES_DIR, save_id + ".eu4");
|
||||
}
|
||||
@ -11,41 +11,6 @@ using ParadoxSaveParser.Lib;
|
||||
|
||||
namespace ParadoxSaveParser.WebAPI;
|
||||
|
||||
public enum SaveFileProcessingStatus
|
||||
{
|
||||
Initialized, Uploading, Parsing, SavingResults, Done, Error
|
||||
}
|
||||
|
||||
public enum Game
|
||||
{
|
||||
Unknown, EU4
|
||||
}
|
||||
|
||||
public class SaveFileMetadata
|
||||
{
|
||||
public required string id { get; init; }
|
||||
public required Game game { get; init; }
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
public static class PathHelper
|
||||
{
|
||||
|
||||
public const string DATA_DIR = "data";
|
||||
public static string SAVES_DIR = Path.Join(DATA_DIR, "saves");
|
||||
public static string GetMetaFilePath(string save_id) => Path.Join(SAVES_DIR, save_id + ".meta.json");
|
||||
public static string GetEU4SaveFilePath(string save_id) => Path.Join(SAVES_DIR, save_id + ".eu4");
|
||||
}
|
||||
|
||||
public class Program
|
||||
{
|
||||
private static ConcurrentDictionary<string, SaveFileMetadata> _saveMetadataStorage = new();
|
||||
|
||||
30
ParadoxSaveParser.WebAPI/SaveFileMetadata.cs
Normal file
30
ParadoxSaveParser.WebAPI/SaveFileMetadata.cs
Normal file
@ -0,0 +1,30 @@
|
||||
using System.IO;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace ParadoxSaveParser.WebAPI;
|
||||
|
||||
public enum SaveFileProcessingStatus
|
||||
{
|
||||
Initialized, Uploading, Parsing, SavingResults, Done, Error
|
||||
}
|
||||
|
||||
public enum Game
|
||||
{
|
||||
Unknown, EU4
|
||||
}
|
||||
|
||||
public class SaveFileMetadata
|
||||
{
|
||||
public required string id { get; init; }
|
||||
public required Game game { get; init; }
|
||||
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);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user