aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Common/Json/Converters/JsonInt32Converter.cs
diff options
context:
space:
mode:
authorcrobibero <cody@robibe.ro>2020-09-01 18:24:42 -0600
committercrobibero <cody@robibe.ro>2020-09-01 18:24:42 -0600
commitf443c534bfac9feea4c92033e85a9aa5097ec4f5 (patch)
tree6d0bcffc442c283f999232c54536c9d774a6f672 /MediaBrowser.Common/Json/Converters/JsonInt32Converter.cs
parent852213d90cd6fe3c4e7b6922ca1f8162bc34c55e (diff)
parent506fc7cbaeb8f82716f84b125ac598ff740bf552 (diff)
Merge remote-tracking branch 'upstream/master' into package-install-repo
Diffstat (limited to 'MediaBrowser.Common/Json/Converters/JsonInt32Converter.cs')
-rw-r--r--MediaBrowser.Common/Json/Converters/JsonInt32Converter.cs40
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);
- }
- }
-}