update to .net 9 and add new OpenAPI packages
This commit is contained in:
parent
80b7f192f1
commit
7e6698c3fb
17 changed files with 451 additions and 1001 deletions
|
@ -15,6 +15,7 @@
|
|||
using System.ComponentModel;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Globalization;
|
||||
using System.Text.Json;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Newtonsoft.Json;
|
||||
using NodaTime;
|
||||
|
@ -23,6 +24,7 @@ using JsonSerializer = Newtonsoft.Json.JsonSerializer;
|
|||
namespace Foxnouns.Backend.Database;
|
||||
|
||||
[JsonConverter(typeof(JsonConverter))]
|
||||
[System.Text.Json.Serialization.JsonConverter(typeof(SystemJsonConverter))]
|
||||
[TypeConverter(typeof(TypeConverter))]
|
||||
public readonly struct Snowflake(ulong value) : IEquatable<Snowflake>
|
||||
{
|
||||
|
@ -96,6 +98,21 @@ public readonly struct Snowflake(ulong value) : IEquatable<Snowflake>
|
|||
// ReSharper disable once ClassNeverInstantiated.Global
|
||||
public class ValueConverter() : ValueConverter<Snowflake, long>(x => x, x => x);
|
||||
|
||||
private class SystemJsonConverter : System.Text.Json.Serialization.JsonConverter<Snowflake>
|
||||
{
|
||||
public override Snowflake Read(
|
||||
ref Utf8JsonReader reader,
|
||||
Type typeToConvert,
|
||||
JsonSerializerOptions options
|
||||
) => ulong.Parse(reader.GetString()!);
|
||||
|
||||
public override void Write(
|
||||
Utf8JsonWriter writer,
|
||||
Snowflake value,
|
||||
JsonSerializerOptions options
|
||||
) => writer.WriteStringValue(value.Value.ToString());
|
||||
}
|
||||
|
||||
private class JsonConverter : JsonConverter<Snowflake>
|
||||
{
|
||||
public override void WriteJson(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue