mirror of
https://github.com/LukeHagar/plexcsharp.git
synced 2025-12-06 12:37:46 +00:00
ci: regenerated with OpenAPI Doc , Speakeasy CLI 1.391.3
This commit is contained in:
61
LukeHagar/PlexAPI/SDK/Utils/BigIntStrConverter.cs
Normal file
61
LukeHagar/PlexAPI/SDK/Utils/BigIntStrConverter.cs
Normal file
@@ -0,0 +1,61 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost when
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
#nullable enable
|
||||
namespace LukeHagar.PlexAPI.SDK.Utils
|
||||
{
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Numerics;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
internal class BigIntStrConverter : JsonConverter
|
||||
{
|
||||
public override bool CanConvert(Type objectType)
|
||||
{
|
||||
var nullableType = Nullable.GetUnderlyingType(objectType);
|
||||
if (nullableType != null)
|
||||
{
|
||||
return nullableType == typeof(BigInteger);
|
||||
}
|
||||
|
||||
return objectType == typeof(BigInteger);
|
||||
}
|
||||
|
||||
public override object? ReadJson(
|
||||
JsonReader reader,
|
||||
Type objectType,
|
||||
object? existingValue,
|
||||
JsonSerializer serializer
|
||||
)
|
||||
{
|
||||
if (reader.Value == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
return BigInteger.Parse(reader.Value.ToString()!);
|
||||
} catch (System.FormatException ex) {
|
||||
throw new Newtonsoft.Json.JsonSerializationException("Could not parse BigInteger", ex);
|
||||
}
|
||||
}
|
||||
|
||||
public override void WriteJson(JsonWriter writer, object? value, JsonSerializer serializer)
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
writer.WriteValue("null");
|
||||
return;
|
||||
}
|
||||
|
||||
writer.WriteValue(((BigInteger)value).ToString(CultureInfo.InvariantCulture));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user