code reformat and cleanup
This commit is contained in:
parent
758388cda0
commit
e9c7c8f5c1
@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="coverlet.collector" Version="6.0.0"/>
|
<PackageReference Include="coverlet.collector" Version="6.0.0"/>
|
||||||
<PackageReference Include="DTLib" Version="1.6.5" />
|
<PackageReference Include="DTLib" Version="1.6.5"/>
|
||||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0"/>
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0"/>
|
||||||
<PackageReference Include="NUnit" Version="3.14.0"/>
|
<PackageReference Include="NUnit" Version="3.14.0"/>
|
||||||
<PackageReference Include="NUnit.Analyzers" Version="3.9.0"/>
|
<PackageReference Include="NUnit.Analyzers" Version="3.9.0"/>
|
||||||
@ -23,7 +23,7 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\ParadoxSaveParser.Lib\ParadoxSaveParser.Lib.csproj" />
|
<ProjectReference Include="..\ParadoxSaveParser.Lib\ParadoxSaveParser.Lib.csproj"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@ -8,24 +8,24 @@ namespace ParadoxSaveParser.Lib.Tests;
|
|||||||
[TestOf(typeof(ISearchExpression))]
|
[TestOf(typeof(ISearchExpression))]
|
||||||
public class SearchExpressionTests
|
public class SearchExpressionTests
|
||||||
{
|
{
|
||||||
byte[] _smallSaveData;
|
|
||||||
|
|
||||||
[SetUp]
|
[SetUp]
|
||||||
public void Setup()
|
public void Setup()
|
||||||
{
|
{
|
||||||
_smallSaveData = "EU4txt a={ b={ c=0 d=1 e=2 } f=3 }".ToBytes();
|
_smallSaveData = "EU4txt a={ b={ c=0 d=1 e=2 } f=3 }".ToBytes();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private byte[] _smallSaveData;
|
||||||
private static JsonSerializerOptions _smallSaveSerializerOptions = new()
|
|
||||||
|
|
||||||
|
private static readonly JsonSerializerOptions _smallSaveSerializerOptions = new()
|
||||||
{
|
{
|
||||||
WriteIndented = false,
|
WriteIndented = false,
|
||||||
Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping,
|
Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping,
|
||||||
MaxDepth = 1024,
|
MaxDepth = 1024
|
||||||
};
|
};
|
||||||
|
|
||||||
internal static string JsonToPdx(string json) =>
|
internal static string JsonToPdx(string json)
|
||||||
json.Substring(1, json.Length - 2)
|
=> json.Substring(1, json.Length - 2)
|
||||||
.Replace(",", " ").Replace("{", "{ ").Replace("}", " }")
|
.Replace(",", " ").Replace("{", "{ ").Replace("}", " }")
|
||||||
.Replace("\"", "").Replace("[", "").Replace("]", "").Replace(":", "=");
|
.Replace("\"", "").Replace("[", "").Replace("]", "").Replace(":", "=");
|
||||||
|
|
||||||
|
|||||||
@ -39,21 +39,21 @@ namespace ParadoxSaveParser.Lib;
|
|||||||
/// </code>
|
/// </code>
|
||||||
public class BufferedEnumerator<T> : IEnumerator<LinkedListNode<T>>
|
public class BufferedEnumerator<T> : IEnumerator<LinkedListNode<T>>
|
||||||
{
|
{
|
||||||
private IEnumerator<T> _enumerator;
|
private readonly int _bufferSize;
|
||||||
private int _bufferSize;
|
|
||||||
LinkedList<T> _llist = new();
|
|
||||||
private LinkedListNode<T>? _currentNode;
|
private LinkedListNode<T>? _currentNode;
|
||||||
private int _currentNodeIndex = -1;
|
private int _currentNodeIndex = -1;
|
||||||
|
private readonly IEnumerator<T> _enumerator;
|
||||||
|
private readonly LinkedList<T> _llist = new();
|
||||||
|
|
||||||
public BufferedEnumerator(IEnumerator<T> enumerator, int bufferSize)
|
public BufferedEnumerator(IEnumerator<T> enumerator, int bufferSize)
|
||||||
{
|
{
|
||||||
_enumerator = enumerator;
|
_enumerator = enumerator;
|
||||||
_bufferSize = bufferSize;
|
_bufferSize = bufferSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool MoveNext()
|
public bool MoveNext()
|
||||||
{
|
{
|
||||||
if(_currentNodeIndex >= _bufferSize / 2)
|
if (_currentNodeIndex >= _bufferSize / 2)
|
||||||
_llist.RemoveFirst();
|
_llist.RemoveFirst();
|
||||||
|
|
||||||
while (_llist.Count < _bufferSize && _enumerator.MoveNext())
|
while (_llist.Count < _bufferSize && _enumerator.MoveNext())
|
||||||
@ -62,7 +62,7 @@ public class BufferedEnumerator<T> : IEnumerator<LinkedListNode<T>>
|
|||||||
}
|
}
|
||||||
if (_llist.Count == 0)
|
if (_llist.Count == 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
_currentNodeIndex++;
|
_currentNodeIndex++;
|
||||||
_currentNode = _currentNode is null ? _llist.First : _currentNode.Next;
|
_currentNode = _currentNode is null ? _llist.First : _currentNode.Next;
|
||||||
return _currentNode is not null;
|
return _currentNode is not null;
|
||||||
|
|||||||
@ -6,17 +6,21 @@ global using System.Text;
|
|||||||
namespace ParadoxSaveParser.Lib;
|
namespace ParadoxSaveParser.Lib;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Sequential parser that doesn't cache anything.
|
/// Sequential parser that doesn't cache anything.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class SaveParserEU4
|
public class SaveParserEU4
|
||||||
{
|
{
|
||||||
protected Stream _saveFile;
|
protected Stream _saveFile;
|
||||||
private BufferedEnumerator<Token> _tokens;
|
|
||||||
private ISearchExpression? _searchExprCurrent;
|
private ISearchExpression? _searchExprCurrent;
|
||||||
|
private readonly BufferedEnumerator<Token> _tokens;
|
||||||
/// <param name="savefile">Uncompressed stream of <c>gamestate</c> file which can be extracted from save archive</param>
|
|
||||||
/// <param name="query">Parsing whole save takes 10 seconds on mid pc and takes 1GB of RAM,
|
/// <param name="savefile">
|
||||||
/// so you should specify what exactly you want to get from save file</param>
|
/// Uncompressed stream of <c>gamestate</c> file which can be extracted from save archive
|
||||||
|
/// </param>
|
||||||
|
/// <param name="query">
|
||||||
|
/// Parsing whole save takes 10 seconds on mid pc and takes 1GB of RAM,
|
||||||
|
/// so you should specify what exactly you want to get from save file
|
||||||
|
/// </param>
|
||||||
public SaveParserEU4(Stream savefile, ISearchExpression? query)
|
public SaveParserEU4(Stream savefile, ISearchExpression? query)
|
||||||
{
|
{
|
||||||
_tokens = new BufferedEnumerator<Token>(LexTextSave(), 5);
|
_tokens = new BufferedEnumerator<Token>(LexTextSave(), 5);
|
||||||
@ -24,13 +28,279 @@ public class SaveParserEU4
|
|||||||
_searchExprCurrent = query;
|
_searchExprCurrent = query;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected IEnumerator<Token> LexTextSave()
|
||||||
|
{
|
||||||
|
string expectedHeader = "EU4txt";
|
||||||
|
byte[] headBytes = new byte[expectedHeader.Length];
|
||||||
|
_saveFile.ReadExactly(headBytes);
|
||||||
|
string headStr = Encoding.UTF8.GetString(headBytes);
|
||||||
|
if (headStr != expectedHeader)
|
||||||
|
throw new Exception($"Invalid gamestate header. Expected '{expectedHeader}', got '{headStr}'.");
|
||||||
|
|
||||||
|
StringBuilder str = new();
|
||||||
|
int line = 2;
|
||||||
|
int column = 0;
|
||||||
|
bool isQuoteOpen = false;
|
||||||
|
bool isStrInQuotes = false;
|
||||||
|
Token strToken = new()
|
||||||
|
{
|
||||||
|
type = TokenType.Invalid,
|
||||||
|
column = -1,
|
||||||
|
line = -1
|
||||||
|
};
|
||||||
|
|
||||||
|
bool TryCompleteStringToken()
|
||||||
|
{
|
||||||
|
if (isQuoteOpen)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// strings in quotes may be empty
|
||||||
|
if (!isStrInQuotes && (str.Length <= 0 || str[0] == '#'))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
strToken = new Token
|
||||||
|
{
|
||||||
|
type = TokenType.StringOrNumber,
|
||||||
|
column = (short)(column - str.Length),
|
||||||
|
line = line,
|
||||||
|
value = str.ToString()
|
||||||
|
};
|
||||||
|
str.Clear();
|
||||||
|
isStrInQuotes = false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (_saveFile.CanRead)
|
||||||
|
{
|
||||||
|
int c = _saveFile.ReadByte();
|
||||||
|
column++;
|
||||||
|
switch (c)
|
||||||
|
{
|
||||||
|
case -1:
|
||||||
|
if (TryCompleteStringToken())
|
||||||
|
yield return strToken;
|
||||||
|
yield break;
|
||||||
|
case '\"':
|
||||||
|
isQuoteOpen = !isQuoteOpen;
|
||||||
|
isStrInQuotes = true;
|
||||||
|
break;
|
||||||
|
case ' ':
|
||||||
|
case '\t':
|
||||||
|
case '\r':
|
||||||
|
if (TryCompleteStringToken())
|
||||||
|
yield return strToken;
|
||||||
|
break;
|
||||||
|
case '\n':
|
||||||
|
if (TryCompleteStringToken())
|
||||||
|
yield return strToken;
|
||||||
|
line++;
|
||||||
|
column = 0;
|
||||||
|
break;
|
||||||
|
case '=':
|
||||||
|
if (TryCompleteStringToken())
|
||||||
|
yield return strToken;
|
||||||
|
yield return new Token
|
||||||
|
{
|
||||||
|
type = TokenType.Equals,
|
||||||
|
line = line, column = (short)column
|
||||||
|
};
|
||||||
|
break;
|
||||||
|
case '{':
|
||||||
|
if (TryCompleteStringToken())
|
||||||
|
yield return strToken;
|
||||||
|
yield return new Token
|
||||||
|
{
|
||||||
|
type = TokenType.BracketOpen,
|
||||||
|
line = line, column = (short)column
|
||||||
|
};
|
||||||
|
break;
|
||||||
|
case '}':
|
||||||
|
if (TryCompleteStringToken())
|
||||||
|
yield return strToken;
|
||||||
|
yield return new Token
|
||||||
|
{
|
||||||
|
type = TokenType.BracketClose,
|
||||||
|
line = line, column = (short)column
|
||||||
|
};
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
// Skip control characters, which are invisible and causing frontend bugs.
|
||||||
|
// I dont know why there are so many of them in strings.
|
||||||
|
if (c >= 0x20)
|
||||||
|
str.Append((char)c);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// doesn't move next
|
||||||
|
private object? ParseValue()
|
||||||
|
{
|
||||||
|
var tok = _tokens.Current.Value;
|
||||||
|
switch (tok.type)
|
||||||
|
{
|
||||||
|
case TokenType.StringOrNumber:
|
||||||
|
if (string.IsNullOrEmpty(tok.value))
|
||||||
|
return string.Empty;
|
||||||
|
if (tok.value[0] != '-' && !char.IsDigit(tok.value[0]))
|
||||||
|
return tok.value;
|
||||||
|
if (tok.value.Contains('.') && double.TryParse(tok.value, out double d))
|
||||||
|
return d;
|
||||||
|
if (long.TryParse(tok.value, out long l))
|
||||||
|
return l;
|
||||||
|
return tok.value;
|
||||||
|
case TokenType.BracketOpen:
|
||||||
|
object obj = ParseListOrDict();
|
||||||
|
return obj;
|
||||||
|
case TokenType.BracketClose:
|
||||||
|
return null;
|
||||||
|
default:
|
||||||
|
throw new UnexpectedTokenException(tok);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// skips next value
|
||||||
|
/// <returns>true if skipped value, false if current token is closing bracket</returns>
|
||||||
|
private bool SkipValue()
|
||||||
|
{
|
||||||
|
var tok = _tokens.Current.Value;
|
||||||
|
if (tok.type == TokenType.BracketOpen)
|
||||||
|
{
|
||||||
|
SkipObject();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return tok.type != TokenType.BracketClose;
|
||||||
|
}
|
||||||
|
|
||||||
|
// skips all tokens inside curly braces block
|
||||||
|
private void SkipObject(int bracketBalance = 1)
|
||||||
|
{
|
||||||
|
while (bracketBalance != 0 && _tokens.MoveNext())
|
||||||
|
{
|
||||||
|
var tok = _tokens.Current.Value;
|
||||||
|
if (tok.type == TokenType.BracketOpen)
|
||||||
|
bracketBalance++;
|
||||||
|
else if (tok.type == TokenType.BracketClose)
|
||||||
|
bracketBalance--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// doesn't move next
|
||||||
|
private object ParseListOrDict()
|
||||||
|
{
|
||||||
|
var first = _tokens.Current.Next;
|
||||||
|
var second = _tokens.Current.Next?.Next;
|
||||||
|
if (first?.Value.type == TokenType.StringOrNumber && second?.Value.type == TokenType.Equals)
|
||||||
|
return ParseDict();
|
||||||
|
|
||||||
|
return ParseList();
|
||||||
|
}
|
||||||
|
|
||||||
|
// moves next
|
||||||
|
private List<object> ParseList()
|
||||||
|
{
|
||||||
|
List<object> list = new();
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
if (!_tokens.MoveNext())
|
||||||
|
throw new Exception("Unexpected end of file");
|
||||||
|
object? value = ParseValue();
|
||||||
|
if (value is null)
|
||||||
|
break;
|
||||||
|
list.Add(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
// moves next
|
||||||
|
private Dictionary<string, List<object>> ParseDict()
|
||||||
|
{
|
||||||
|
Dictionary<string, List<object>> dict = new();
|
||||||
|
|
||||||
|
// root is a dict without closing bracket, so this method must check _tokenIndex < _tokens.Count
|
||||||
|
for (int localIndex = 0; _tokens.MoveNext(); localIndex++)
|
||||||
|
{
|
||||||
|
var tok = _tokens.Current.Value;
|
||||||
|
// end of dictionary
|
||||||
|
if (tok.type == TokenType.BracketClose)
|
||||||
|
break;
|
||||||
|
|
||||||
|
// Saves may contain some blocks without key.
|
||||||
|
// Such blocks are skipped because idk where to put them.
|
||||||
|
// Example: `technology_group=tech_cannorian{ }
|
||||||
|
// { } { } { }`
|
||||||
|
if (tok.type == TokenType.BracketOpen)
|
||||||
|
{
|
||||||
|
SkipObject();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tok.type != TokenType.StringOrNumber)
|
||||||
|
throw new UnexpectedTokenException(tok);
|
||||||
|
|
||||||
|
string key = tok.value!;
|
||||||
|
|
||||||
|
// next token should be `=` or `{`
|
||||||
|
if (!_tokens.MoveNext())
|
||||||
|
throw new UnexpectedTokenException(tok);
|
||||||
|
tok = _tokens.Current.Value;
|
||||||
|
if (tok.type == TokenType.Equals)
|
||||||
|
{
|
||||||
|
// skip `=`
|
||||||
|
if (!_tokens.MoveNext())
|
||||||
|
throw new UnexpectedTokenException(tok);
|
||||||
|
}
|
||||||
|
// Saves may contain object definition without `=`.
|
||||||
|
// Example: `map_area_data {` instead of `map_area_data = {`
|
||||||
|
else if (tok.type != TokenType.BracketOpen)
|
||||||
|
{
|
||||||
|
throw new UnexpectedTokenException(tok);
|
||||||
|
}
|
||||||
|
|
||||||
|
ISearchExpression? searchExprNext = null;
|
||||||
|
if (_searchExprCurrent != null
|
||||||
|
&& !_searchExprCurrent.DoesMatch(new SearchArgs(key, localIndex), out searchExprNext))
|
||||||
|
{
|
||||||
|
SkipValue();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
var searExpressionPrevious = _searchExprCurrent;
|
||||||
|
_searchExprCurrent = searchExprNext;
|
||||||
|
object? value = ParseValue();
|
||||||
|
if (value is null)
|
||||||
|
throw new UnexpectedTokenException(_tokens.Current.Value);
|
||||||
|
_searchExprCurrent = searExpressionPrevious;
|
||||||
|
|
||||||
|
if (!dict.TryGetValue(key, out var list))
|
||||||
|
{
|
||||||
|
list = new List<object>();
|
||||||
|
dict.Add(key, list);
|
||||||
|
}
|
||||||
|
|
||||||
|
list.Add(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
return dict;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Dictionary<string, List<object>> Parse()
|
||||||
|
{
|
||||||
|
var root = ParseDict();
|
||||||
|
return root;
|
||||||
|
}
|
||||||
|
|
||||||
protected enum TokenType : byte
|
protected enum TokenType : byte
|
||||||
{
|
{
|
||||||
Invalid,
|
Invalid,
|
||||||
StringOrNumber,
|
StringOrNumber,
|
||||||
Equals,
|
Equals,
|
||||||
BracketOpen,
|
BracketOpen,
|
||||||
BracketClose,
|
BracketClose
|
||||||
}
|
}
|
||||||
|
|
||||||
protected struct Token
|
protected struct Token
|
||||||
@ -63,7 +333,7 @@ public class SaveParserEU4
|
|||||||
default:
|
default:
|
||||||
throw new ArgumentOutOfRangeException(type.ToString());
|
throw new ArgumentOutOfRangeException(type.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
return $"{line}:{column} '{s}'";
|
return $"{line}:{column} '{s}'";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -72,268 +342,7 @@ public class SaveParserEU4
|
|||||||
{
|
{
|
||||||
public UnexpectedTokenException(Token token) :
|
public UnexpectedTokenException(Token token) :
|
||||||
base($"Unexpected token: {token}")
|
base($"Unexpected token: {token}")
|
||||||
{}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected IEnumerator<Token> LexTextSave()
|
|
||||||
{
|
|
||||||
string expectedHeader = "EU4txt";
|
|
||||||
byte[] headBytes = new byte[expectedHeader.Length];
|
|
||||||
_saveFile.ReadExactly(headBytes);
|
|
||||||
string headStr = Encoding.UTF8.GetString(headBytes);
|
|
||||||
if (headStr != expectedHeader)
|
|
||||||
throw new Exception($"Invalid gamestate header. Expected '{expectedHeader}', got '{headStr}'.");
|
|
||||||
|
|
||||||
StringBuilder str = new();
|
|
||||||
int line = 2;
|
|
||||||
int column = 0;
|
|
||||||
bool isQuoteOpen = false;
|
|
||||||
bool isStrInQuotes = false;
|
|
||||||
Token strToken = new()
|
|
||||||
{
|
{
|
||||||
type = TokenType.Invalid,
|
|
||||||
column = -1,
|
|
||||||
line = -1
|
|
||||||
};
|
|
||||||
|
|
||||||
bool TryCompleteStringToken()
|
|
||||||
{
|
|
||||||
if (isQuoteOpen)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
// strings in quotes may be empty
|
|
||||||
if (!isStrInQuotes && (str.Length <= 0 || str[0] == '#'))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
strToken = new Token
|
|
||||||
{
|
|
||||||
type = TokenType.StringOrNumber,
|
|
||||||
column = (short)(column - str.Length),
|
|
||||||
line = line,
|
|
||||||
value = str.ToString()
|
|
||||||
};
|
|
||||||
str.Clear();
|
|
||||||
isStrInQuotes = false;
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
while (_saveFile.CanRead)
|
|
||||||
{
|
|
||||||
int c = _saveFile.ReadByte();
|
|
||||||
column++;
|
|
||||||
switch (c)
|
|
||||||
{
|
|
||||||
case -1:
|
|
||||||
if(TryCompleteStringToken())
|
|
||||||
yield return strToken;
|
|
||||||
yield break;
|
|
||||||
case '\"':
|
|
||||||
isQuoteOpen = !isQuoteOpen;
|
|
||||||
isStrInQuotes = true;
|
|
||||||
break;
|
|
||||||
case ' ':
|
|
||||||
case '\t':
|
|
||||||
case '\r':
|
|
||||||
if(TryCompleteStringToken())
|
|
||||||
yield return strToken;
|
|
||||||
break;
|
|
||||||
case '\n':
|
|
||||||
if(TryCompleteStringToken())
|
|
||||||
yield return strToken;
|
|
||||||
line++;
|
|
||||||
column = 0;
|
|
||||||
break;
|
|
||||||
case '=':
|
|
||||||
if(TryCompleteStringToken())
|
|
||||||
yield return strToken;
|
|
||||||
yield return new Token
|
|
||||||
{
|
|
||||||
type = TokenType.Equals,
|
|
||||||
line = line, column = (short)column
|
|
||||||
};
|
|
||||||
break;
|
|
||||||
case '{':
|
|
||||||
if(TryCompleteStringToken())
|
|
||||||
yield return strToken;
|
|
||||||
yield return new Token
|
|
||||||
{
|
|
||||||
type = TokenType.BracketOpen,
|
|
||||||
line = line, column = (short)column
|
|
||||||
};
|
|
||||||
break;
|
|
||||||
case '}':
|
|
||||||
if(TryCompleteStringToken())
|
|
||||||
yield return strToken;
|
|
||||||
yield return new Token
|
|
||||||
{
|
|
||||||
type = TokenType.BracketClose,
|
|
||||||
line = line, column = (short)column
|
|
||||||
};
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
// Skip control characters, which are invisible and causing frontend bugs.
|
|
||||||
// I dont know why there are so many of them in strings.
|
|
||||||
if(c >= 0x20)
|
|
||||||
str.Append((char)c);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// doesn't move next
|
|
||||||
private object? ParseValue()
|
|
||||||
{
|
|
||||||
Token tok = _tokens.Current.Value;
|
|
||||||
switch (tok.type)
|
|
||||||
{
|
|
||||||
case TokenType.StringOrNumber:
|
|
||||||
if(string.IsNullOrEmpty(tok.value))
|
|
||||||
return string.Empty;
|
|
||||||
if (tok.value[0] != '-' && !char.IsDigit(tok.value[0]))
|
|
||||||
return tok.value;
|
|
||||||
if(tok.value.Contains('.') && Double.TryParse(tok.value, out double d))
|
|
||||||
return d;
|
|
||||||
if (Int64.TryParse(tok.value, out long l))
|
|
||||||
return l;
|
|
||||||
return tok.value;
|
|
||||||
case TokenType.BracketOpen:
|
|
||||||
var obj = ParseListOrDict();
|
|
||||||
return obj;
|
|
||||||
case TokenType.BracketClose:
|
|
||||||
return null;
|
|
||||||
default:
|
|
||||||
throw new UnexpectedTokenException(tok);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// skips next value
|
|
||||||
/// <returns>true if skipped value, false if current token is closing bracket</returns>
|
|
||||||
private bool SkipValue()
|
|
||||||
{
|
|
||||||
Token tok = _tokens.Current.Value;
|
|
||||||
if (tok.type == TokenType.BracketOpen)
|
|
||||||
{
|
|
||||||
SkipObject();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return tok.type != TokenType.BracketClose;
|
|
||||||
}
|
|
||||||
|
|
||||||
// skips all tokens inside curly braces block
|
|
||||||
private void SkipObject(int bracketBalance = 1)
|
|
||||||
{
|
|
||||||
while (bracketBalance != 0 && _tokens.MoveNext())
|
|
||||||
{
|
|
||||||
Token tok = _tokens.Current.Value;
|
|
||||||
if (tok.type == TokenType.BracketOpen)
|
|
||||||
bracketBalance++;
|
|
||||||
else if (tok.type == TokenType.BracketClose)
|
|
||||||
bracketBalance--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// doesn't move next
|
|
||||||
private object ParseListOrDict()
|
|
||||||
{
|
|
||||||
var first = _tokens.Current.Next;
|
|
||||||
var second = _tokens.Current.Next?.Next;
|
|
||||||
if (first?.Value.type == TokenType.StringOrNumber && second?.Value.type == TokenType.Equals)
|
|
||||||
return ParseDict();
|
|
||||||
|
|
||||||
return ParseList();
|
|
||||||
}
|
|
||||||
|
|
||||||
// moves next
|
|
||||||
private List<object> ParseList()
|
|
||||||
{
|
|
||||||
List<object> list = new();
|
|
||||||
while(true)
|
|
||||||
{
|
|
||||||
if(!_tokens.MoveNext())
|
|
||||||
throw new Exception("Unexpected end of file");
|
|
||||||
object? value = ParseValue();
|
|
||||||
if (value is null)
|
|
||||||
break;
|
|
||||||
list.Add(value);
|
|
||||||
}
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
// moves next
|
|
||||||
private Dictionary<string, List<object>> ParseDict()
|
|
||||||
{
|
|
||||||
Dictionary<string, List<object>> dict = new();
|
|
||||||
|
|
||||||
// root is a dict without closing bracket, so this method must check _tokenIndex < _tokens.Count
|
|
||||||
for (int localIndex = 0; _tokens.MoveNext(); localIndex++)
|
|
||||||
{
|
|
||||||
Token tok = _tokens.Current.Value;
|
|
||||||
// end of dictionary
|
|
||||||
if (tok.type == TokenType.BracketClose)
|
|
||||||
break;
|
|
||||||
|
|
||||||
// Saves may contain some blocks without key.
|
|
||||||
// Such blocks are skipped because idk where to put them.
|
|
||||||
// Example: `technology_group=tech_cannorian{ }
|
|
||||||
// { } { } { }`
|
|
||||||
if (tok.type == TokenType.BracketOpen)
|
|
||||||
{
|
|
||||||
SkipObject();
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(tok.type != TokenType.StringOrNumber)
|
|
||||||
throw new UnexpectedTokenException(tok);
|
|
||||||
|
|
||||||
string key = tok.value!;
|
|
||||||
|
|
||||||
// next token should be `=` or `{`
|
|
||||||
if(!_tokens.MoveNext())
|
|
||||||
throw new UnexpectedTokenException(tok);
|
|
||||||
tok = _tokens.Current.Value;
|
|
||||||
if (tok.type == TokenType.Equals)
|
|
||||||
{
|
|
||||||
// skip `=`
|
|
||||||
if (!_tokens.MoveNext())
|
|
||||||
throw new UnexpectedTokenException(tok);
|
|
||||||
}
|
|
||||||
// Saves may contain object definition without `=`.
|
|
||||||
// Example: `map_area_data {` instead of `map_area_data = {`
|
|
||||||
else if (tok.type != TokenType.BracketOpen)
|
|
||||||
throw new UnexpectedTokenException(tok);
|
|
||||||
|
|
||||||
ISearchExpression? searchExprNext = null;
|
|
||||||
if (_searchExprCurrent != null
|
|
||||||
&& !_searchExprCurrent.DoesMatch(new SearchArgs(key, localIndex), out searchExprNext))
|
|
||||||
{
|
|
||||||
SkipValue();
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
var searExpressionPrevious = _searchExprCurrent;
|
|
||||||
_searchExprCurrent = searchExprNext;
|
|
||||||
object? value = ParseValue();
|
|
||||||
if (value is null)
|
|
||||||
throw new UnexpectedTokenException(_tokens.Current.Value);
|
|
||||||
_searchExprCurrent = searExpressionPrevious;
|
|
||||||
|
|
||||||
if(!dict.TryGetValue(key, out List<object>? list))
|
|
||||||
{
|
|
||||||
list = new List<object>();
|
|
||||||
dict.Add(key, list);
|
|
||||||
}
|
|
||||||
list.Add(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
return dict;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Dictionary<string, List<object>> Parse()
|
|
||||||
{
|
|
||||||
var root = ParseDict();
|
|
||||||
return root;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -9,15 +9,15 @@ public interface ISearchExpression
|
|||||||
|
|
||||||
public static class SearchExpressionCompiler
|
public static class SearchExpressionCompiler
|
||||||
{
|
{
|
||||||
private static bool CharEqualsAndNotEscaped(char c, ReadOnlySpan<char> chars, int i) =>
|
private static bool CharEqualsAndNotEscaped(char c, ReadOnlySpan<char> chars, int i)
|
||||||
chars[i] == c && (i < 1 || chars[i - 1] != '\\') && (i < 2 || chars[i - 2] != '\\');
|
=> chars[i] == c && (i < 1 || chars[i - 1] != '\\') && (i < 2 || chars[i - 2] != '\\');
|
||||||
|
|
||||||
public static ISearchExpression Compile(ReadOnlySpan<char> query)
|
public static ISearchExpression Compile(ReadOnlySpan<char> query)
|
||||||
{
|
{
|
||||||
if(query.IsEmpty)
|
if (query.IsEmpty)
|
||||||
throw new ArgumentNullException(nameof(query));
|
throw new ArgumentNullException(nameof(query));
|
||||||
|
|
||||||
if(query[0] is '(')
|
if (query[0] is '(')
|
||||||
{
|
{
|
||||||
var subExprs = new List<ISearchExpression>();
|
var subExprs = new List<ISearchExpression>();
|
||||||
int supExprBegin = 1;
|
int supExprBegin = 1;
|
||||||
@ -25,9 +25,13 @@ public static class SearchExpressionCompiler
|
|||||||
for (int i = supExprBegin; i < query.Length && bracketBalance != 0; i++)
|
for (int i = supExprBegin; i < query.Length && bracketBalance != 0; i++)
|
||||||
{
|
{
|
||||||
if (CharEqualsAndNotEscaped('(', query, i))
|
if (CharEqualsAndNotEscaped('(', query, i))
|
||||||
|
{
|
||||||
bracketBalance++;
|
bracketBalance++;
|
||||||
|
}
|
||||||
else if (CharEqualsAndNotEscaped(')', query, i))
|
else if (CharEqualsAndNotEscaped(')', query, i))
|
||||||
|
{
|
||||||
bracketBalance--;
|
bracketBalance--;
|
||||||
|
}
|
||||||
else if (bracketBalance == 1 && CharEqualsAndNotEscaped('|', query, i))
|
else if (bracketBalance == 1 && CharEqualsAndNotEscaped('|', query, i))
|
||||||
{
|
{
|
||||||
var subPart = query.Slice(supExprBegin, i - supExprBegin);
|
var subPart = query.Slice(supExprBegin, i - supExprBegin);
|
||||||
@ -37,14 +41,14 @@ public static class SearchExpressionCompiler
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(query[^1] != ')')
|
if (query[^1] != ')')
|
||||||
throw new NotImplementedException("Expressions after ')' are not supported");
|
throw new NotImplementedException("Expressions after ')' are not supported");
|
||||||
|
|
||||||
if (bracketBalance > 0)
|
if (bracketBalance > 0)
|
||||||
throw new Exception("Too many opening brackets");
|
throw new Exception("Too many opening brackets");
|
||||||
if (bracketBalance < 0)
|
if (bracketBalance < 0)
|
||||||
throw new Exception("Too many closing brackets");
|
throw new Exception("Too many closing brackets");
|
||||||
|
|
||||||
var subPartLast = query.Slice(supExprBegin, query.Length - supExprBegin - 1);
|
var subPartLast = query.Slice(supExprBegin, query.Length - supExprBegin - 1);
|
||||||
var subExprLast = Compile(subPartLast);
|
var subExprLast = Compile(subPartLast);
|
||||||
subExprs.Add(subExprLast);
|
subExprs.Add(subExprLast);
|
||||||
@ -54,35 +58,31 @@ public static class SearchExpressionCompiler
|
|||||||
int partBeforePointLength = 0;
|
int partBeforePointLength = 0;
|
||||||
while (partBeforePointLength < query.Length)
|
while (partBeforePointLength < query.Length)
|
||||||
{
|
{
|
||||||
if(CharEqualsAndNotEscaped('.', query, partBeforePointLength))
|
if (CharEqualsAndNotEscaped('.', query, partBeforePointLength))
|
||||||
break;
|
break;
|
||||||
partBeforePointLength++;
|
partBeforePointLength++;
|
||||||
}
|
}
|
||||||
|
|
||||||
var part = query.Slice(0, partBeforePointLength);
|
var part = query.Slice(0, partBeforePointLength);
|
||||||
ReadOnlySpan<char> remaining = default;
|
ReadOnlySpan<char> remaining = default;
|
||||||
if (partBeforePointLength < query.Length)
|
if (partBeforePointLength < query.Length)
|
||||||
remaining = query.Slice(partBeforePointLength + 1);
|
remaining = query.Slice(partBeforePointLength + 1);
|
||||||
if (part is "*")
|
if (part is "*") return new AnyMatchExpression(remaining.IsEmpty ? null : Compile(remaining));
|
||||||
{
|
|
||||||
return new AnyMatchExpression(remaining.IsEmpty ? null : Compile(remaining));
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int j = 0; j < part.Length; j++)
|
for (int j = 0; j < part.Length; j++)
|
||||||
{
|
if (CharEqualsAndNotEscaped('*', part, j))
|
||||||
if(CharEqualsAndNotEscaped('*', part, j))
|
|
||||||
throw new NotImplementedException("pattern matching other than '*' is not implemented yet");
|
throw new NotImplementedException("pattern matching other than '*' is not implemented yet");
|
||||||
}
|
|
||||||
|
|
||||||
if (part[0] is '[')
|
if (part[0] is '[')
|
||||||
{
|
{
|
||||||
part = part.Slice(1, part.Length - 2);
|
part = part.Slice(1, part.Length - 2);
|
||||||
return new IndexMatchExpression(int.Parse(part), remaining.IsEmpty ? null : Compile(remaining));
|
return new IndexMatchExpression(int.Parse(part), remaining.IsEmpty ? null : Compile(remaining));
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ExactMatchExpression(part.ToString(), remaining.IsEmpty ? null : Compile(remaining));
|
return new ExactMatchExpression(part.ToString(), remaining.IsEmpty ? null : Compile(remaining));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private record AnyMatchExpression(ISearchExpression? next) : ISearchExpression
|
private record AnyMatchExpression(ISearchExpression? next) : ISearchExpression
|
||||||
{
|
{
|
||||||
public bool DoesMatch(SearchArgs args, out ISearchExpression? nextSearchExpression)
|
public bool DoesMatch(SearchArgs args, out ISearchExpression? nextSearchExpression)
|
||||||
@ -91,19 +91,15 @@ public static class SearchExpressionCompiler
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private record MultipleMatchExpression(List<ISearchExpression> subExprs) : ISearchExpression
|
private record MultipleMatchExpression(List<ISearchExpression> subExprs) : ISearchExpression
|
||||||
{
|
{
|
||||||
public bool DoesMatch(SearchArgs args, out ISearchExpression? nextSearchExpression)
|
public bool DoesMatch(SearchArgs args, out ISearchExpression? nextSearchExpression)
|
||||||
{
|
{
|
||||||
foreach (var e in subExprs)
|
foreach (var e in subExprs)
|
||||||
{
|
if (e.DoesMatch(args, out nextSearchExpression))
|
||||||
if(e.DoesMatch(args, out nextSearchExpression))
|
|
||||||
{
|
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
nextSearchExpression = null;
|
nextSearchExpression = null;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -118,12 +114,12 @@ public static class SearchExpressionCompiler
|
|||||||
nextSearchExpression = next;
|
nextSearchExpression = next;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
nextSearchExpression = null;
|
nextSearchExpression = null;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private record ExactMatchExpression(string key, ISearchExpression? next) : ISearchExpression
|
private record ExactMatchExpression(string key, ISearchExpression? next) : ISearchExpression
|
||||||
{
|
{
|
||||||
public bool DoesMatch(SearchArgs args, out ISearchExpression? nextSearchExpression)
|
public bool DoesMatch(SearchArgs args, out ISearchExpression? nextSearchExpression)
|
||||||
@ -133,9 +129,9 @@ public static class SearchExpressionCompiler
|
|||||||
nextSearchExpression = next;
|
nextSearchExpression = next;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
nextSearchExpression = null;
|
nextSearchExpression = null;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -5,10 +5,10 @@ namespace ParadoxSaveParser.WebAPI;
|
|||||||
public class Config
|
public class Config
|
||||||
{
|
{
|
||||||
public const int ActualVersion = 1;
|
public const int ActualVersion = 1;
|
||||||
|
|
||||||
public int Version = ActualVersion;
|
|
||||||
public string BaseUrl = "http://127.0.0.1:5226/";
|
public string BaseUrl = "http://127.0.0.1:5226/";
|
||||||
|
|
||||||
|
public int Version = ActualVersion;
|
||||||
|
|
||||||
public static Config FromDtsod(DtsodV23 d)
|
public static Config FromDtsod(DtsodV23 d)
|
||||||
{
|
{
|
||||||
var cfg = new Config
|
var cfg = new Config
|
||||||
@ -18,16 +18,16 @@ public class Config
|
|||||||
};
|
};
|
||||||
if (cfg.Version < ActualVersion)
|
if (cfg.Version < ActualVersion)
|
||||||
throw new Exception($"config is obsolete (config v{cfg.Version} < program v{ActualVersion})");
|
throw new Exception($"config is obsolete (config v{cfg.Version} < program v{ActualVersion})");
|
||||||
if(cfg.Version > ActualVersion)
|
if (cfg.Version > ActualVersion)
|
||||||
throw new Exception($"program is obsolete (config v{cfg.Version} > program v{ActualVersion})");
|
throw new Exception($"program is obsolete (config v{cfg.Version} > program v{ActualVersion})");
|
||||||
return cfg;
|
return cfg;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DtsodV23 ToDtsod() =>
|
public DtsodV23 ToDtsod()
|
||||||
new()
|
=> new()
|
||||||
{
|
{
|
||||||
{ "version", Version },
|
{ "version", Version },
|
||||||
{ "baseUrl", BaseUrl },
|
{ "baseUrl", BaseUrl }
|
||||||
};
|
};
|
||||||
|
|
||||||
public override string ToString() => ToDtsod().ToString();
|
public override string ToString() => ToDtsod().ToString();
|
||||||
|
|||||||
@ -9,10 +9,10 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\ParadoxSaveParser.Lib\ParadoxSaveParser.Lib.csproj" />
|
<ProjectReference Include="..\ParadoxSaveParser.Lib\ParadoxSaveParser.Lib.csproj"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="DTLib.Web" Version="1.2.2" />
|
<PackageReference Include="DTLib.Web" Version="1.2.2"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@ -4,7 +4,10 @@ public static class PathHelper
|
|||||||
{
|
{
|
||||||
public static readonly IOPath DATA_DIR = "data";
|
public static readonly IOPath DATA_DIR = "data";
|
||||||
public static readonly IOPath SAVES_DIR = Path.Concat(DATA_DIR, "saves");
|
public static readonly IOPath SAVES_DIR = Path.Concat(DATA_DIR, "saves");
|
||||||
|
|
||||||
public static IOPath GetMetaFilePath(string save_id) => Path.Concat(SAVES_DIR, save_id + ".meta.json");
|
public static IOPath GetMetaFilePath(string save_id) => Path.Concat(SAVES_DIR, save_id + ".meta.json");
|
||||||
|
|
||||||
public static IOPath GetSaveFilePath(string save_id) => Path.Concat(SAVES_DIR, save_id + ".eu4");
|
public static IOPath GetSaveFilePath(string save_id) => Path.Concat(SAVES_DIR, save_id + ".eu4");
|
||||||
|
|
||||||
public static IOPath GetParsedSaveFilePath(string save_id) => Path.Concat(SAVES_DIR, save_id + ".parsed.json");
|
public static IOPath GetParsedSaveFilePath(string save_id) => Path.Concat(SAVES_DIR, save_id + ".parsed.json");
|
||||||
}
|
}
|
||||||
@ -14,7 +14,7 @@ public partial class Program
|
|||||||
Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping,
|
Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping,
|
||||||
MaxDepth = 1024
|
MaxDepth = 1024
|
||||||
};
|
};
|
||||||
|
|
||||||
public static async Task<HttpStatusCode> ReturnResponseString(HttpListenerContext ctx,
|
public static async Task<HttpStatusCode> ReturnResponseString(HttpListenerContext ctx,
|
||||||
string value, HttpStatusCode statusCode = HttpStatusCode.OK)
|
string value, HttpStatusCode statusCode = HttpStatusCode.OK)
|
||||||
{
|
{
|
||||||
@ -53,6 +53,17 @@ public partial class Program
|
|||||||
return error.StatusCode;
|
return error.StatusCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
internal static ValueOrError<string> GetRequestQueryValue(HttpListenerContext ctx, string paramName)
|
||||||
|
{
|
||||||
|
string[]? values = ctx.Request.QueryString.GetValues(paramName);
|
||||||
|
string? value = values?.FirstOrDefault();
|
||||||
|
if (string.IsNullOrEmpty(value))
|
||||||
|
return new ErrorMessage(HttpStatusCode.BadRequest,
|
||||||
|
$"No request parameter '{paramName}' provided");
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
public record ErrorMessage
|
public record ErrorMessage
|
||||||
{
|
{
|
||||||
public ErrorMessage(HttpStatusCode statusCode, string message)
|
public ErrorMessage(HttpStatusCode statusCode, string message)
|
||||||
@ -83,15 +94,4 @@ public partial class Program
|
|||||||
|
|
||||||
public static implicit operator ValueOrError<T>(ErrorMessage e) => new(default, e);
|
public static implicit operator ValueOrError<T>(ErrorMessage e) => new(default, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
internal static ValueOrError<string> GetRequestQueryValue(HttpListenerContext ctx, string paramName)
|
|
||||||
{
|
|
||||||
string[]? values = ctx.Request.QueryString.GetValues(paramName);
|
|
||||||
string? value = values?.FirstOrDefault();
|
|
||||||
if (string.IsNullOrEmpty(value))
|
|
||||||
return new ErrorMessage(HttpStatusCode.BadRequest,
|
|
||||||
$"No request parameter '{paramName}' provided");
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@ -4,26 +4,31 @@ namespace ParadoxSaveParser.WebAPI;
|
|||||||
|
|
||||||
public enum SaveFileProcessingStatus
|
public enum SaveFileProcessingStatus
|
||||||
{
|
{
|
||||||
Initialized, Uploading, Uploaded, Parsing, SavingResults, Done
|
Initialized,
|
||||||
|
Uploading,
|
||||||
|
Uploaded,
|
||||||
|
Parsing,
|
||||||
|
SavingResults,
|
||||||
|
Done
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum Game
|
public enum Game
|
||||||
{
|
{
|
||||||
Unknown, EU4
|
Unknown,
|
||||||
|
EU4
|
||||||
}
|
}
|
||||||
|
|
||||||
public class SaveFileMetadata
|
public class SaveFileMetadata
|
||||||
{
|
{
|
||||||
|
private static readonly JsonSerializerOptions _jsonOptions = new() { WriteIndented = true };
|
||||||
public required string id { get; init; }
|
public required string id { get; init; }
|
||||||
|
|
||||||
[JsonConverter(typeof(JsonStringEnumConverter))]
|
[JsonConverter(typeof(JsonStringEnumConverter))]
|
||||||
public required Game game { get; init; }
|
public required Game game { get; init; }
|
||||||
|
|
||||||
[JsonConverter(typeof(JsonStringEnumConverter))]
|
[JsonConverter(typeof(JsonStringEnumConverter))]
|
||||||
public required SaveFileProcessingStatus status { get; set; }
|
public required SaveFileProcessingStatus status { get; set; }
|
||||||
|
|
||||||
|
|
||||||
private static readonly JsonSerializerOptions _jsonOptions = new() { WriteIndented = true };
|
|
||||||
public void SaveToFile()
|
public void SaveToFile()
|
||||||
{
|
{
|
||||||
using var metaFile = File.OpenWrite(PathHelper.GetMetaFilePath(id));
|
using var metaFile = File.OpenWrite(PathHelper.GetMetaFilePath(id));
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user