mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-14 09:40:10 +00:00
feat: upgrade to .NET 6, refactor everything
This commit is contained in:
parent
d28e99ba43
commit
1918c56937
314 changed files with 27954 additions and 27966 deletions
|
|
@ -1,28 +1,26 @@
|
|||
using System;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
using Myriad.Gateway;
|
||||
|
||||
namespace Myriad.Serialization
|
||||
namespace Myriad.Serialization;
|
||||
|
||||
public class ShardInfoJsonConverter: JsonConverter<ShardInfo>
|
||||
{
|
||||
public class ShardInfoJsonConverter: JsonConverter<ShardInfo>
|
||||
public override ShardInfo? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
||||
{
|
||||
public override ShardInfo? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
||||
{
|
||||
var arr = JsonSerializer.Deserialize<int[]>(ref reader);
|
||||
if (arr?.Length != 2)
|
||||
throw new JsonException("Expected shard info as array of length 2");
|
||||
var arr = JsonSerializer.Deserialize<int[]>(ref reader);
|
||||
if (arr?.Length != 2)
|
||||
throw new JsonException("Expected shard info as array of length 2");
|
||||
|
||||
return new ShardInfo(arr[0], arr[1]);
|
||||
}
|
||||
return new ShardInfo(arr[0], arr[1]);
|
||||
}
|
||||
|
||||
public override void Write(Utf8JsonWriter writer, ShardInfo value, JsonSerializerOptions options)
|
||||
{
|
||||
writer.WriteStartArray();
|
||||
writer.WriteNumberValue(value.ShardId);
|
||||
writer.WriteNumberValue(value.NumShards);
|
||||
writer.WriteEndArray();
|
||||
}
|
||||
public override void Write(Utf8JsonWriter writer, ShardInfo value, JsonSerializerOptions options)
|
||||
{
|
||||
writer.WriteStartArray();
|
||||
writer.WriteNumberValue(value.ShardId);
|
||||
writer.WriteNumberValue(value.NumShards);
|
||||
writer.WriteEndArray();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue