diff options
| author | crobibero <cody@robibe.ro> | 2020-08-31 10:32:28 -0600 |
|---|---|---|
| committer | crobibero <cody@robibe.ro> | 2020-08-31 10:32:28 -0600 |
| commit | 95402df88408b96300e627b9962d0e4db2e4c7c5 (patch) | |
| tree | 91cc4d6c271e99256a39f3cacbe1a49bb40ef71a /MediaBrowser.Common/Json/Converters/JsonInt32Converter.cs | |
| parent | e48df7da5e3d3eb81f68e71c0fe27a64063f00ac (diff) | |
| parent | 95142643f6c98fe4380c63ba9b3055fd3a637466 (diff) | |
Merge remote-tracking branch 'upstream/master' into default-http-client
Diffstat (limited to 'MediaBrowser.Common/Json/Converters/JsonInt32Converter.cs')
| -rw-r--r-- | MediaBrowser.Common/Json/Converters/JsonInt32Converter.cs | 40 |
1 files changed, 0 insertions, 40 deletions
diff --git a/MediaBrowser.Common/Json/Converters/JsonInt32Converter.cs b/MediaBrowser.Common/Json/Converters/JsonInt32Converter.cs deleted file mode 100644 index 70c375b8c..000000000 --- a/MediaBrowser.Common/Json/Converters/JsonInt32Converter.cs +++ /dev/null @@ -1,40 +0,0 @@ -using System; -using System.Buffers; -using System.Buffers.Text; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace MediaBrowser.Common.Json.Converters -{ - /// <summary> - /// Converts a GUID object or value to/from JSON. - /// </summary> - public class JsonInt32Converter : JsonConverter<int> - { - /// <inheritdoc /> - public override int Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) - { - if (reader.TokenType == JsonTokenType.String) - { - ReadOnlySpan<byte> span = reader.HasValueSequence ? reader.ValueSequence.ToArray() : reader.ValueSpan; - if (Utf8Parser.TryParse(span, out int number, out int bytesConsumed) && span.Length == bytesConsumed) - { - return number; - } - - if (int.TryParse(reader.GetString(), out number)) - { - return number; - } - } - - return reader.GetInt32(); - } - - /// <inheritdoc /> - public override void Write(Utf8JsonWriter writer, int value, JsonSerializerOptions options) - { - writer.WriteNumberValue(value); - } - } -} |
