1
0
mirror of synced 2024-11-28 00:20:53 +01:00
TaikoLocalServer/LocalSaveModScoreMigrator/ScoreRankConverter.cs

22 lines
702 B
C#
Raw Normal View History

2023-09-09 14:58:20 +02:00
using System.Diagnostics;
using System.Text.Json;
using System.Text.Json.Serialization;
using SharedProject.Enums;
namespace LocalSaveModScoreMigrator;
public class ScoreRankConverter : JsonConverter<ScoreRank>
{
public override ScoreRank Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
Debug.Assert(typeToConvert == typeof(ScoreRank));
var scoreRankInt = reader.GetInt32() + 1;
return (ScoreRank)scoreRankInt;
}
public override void Write(Utf8JsonWriter writer, ScoreRank value, JsonSerializerOptions options)
{
var scoreRank = (int)value - 1;
writer.WriteStringValue(scoreRank.ToString());
}
}