public override Color Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { int c; switch (reader.TokenType) { case JsonTokenType.Number: { c = reader.GetInt32(); break; } case JsonTokenType.String when options.NumberHandling.HasFlag(JsonNumberHandling.AllowReadingFromString): { c = int.Parse(reader.GetString() !); break; } default: { throw new JsonException(); } } return(Color.FromArgb((int)(c | 0xFF000000))); }
public override Snowflake Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { switch (reader.TokenType) { case JsonTokenType.Number: { return(reader.GetUInt64()); } case JsonTokenType.String when options.NumberHandling.HasFlag(JsonNumberHandling.AllowReadingFromString): { return(ulong.Parse(reader.GetString() !)); } default: { throw new JsonException(); } } }