mirror of
https://github.com/Tribufu/TribufuDotNet
synced 2026-08-09 12:51:06 +00:00
Migrate to new tribufu project structure (#2)
* Migrate to new tribufu project structure * Update .gitignore * Remove old api files * Update Directory.Build.props * Rename solution
This commit is contained in:
parent
be25ee8fe3
commit
7e8e192dc3
115 changed files with 41 additions and 262 deletions
|
|
@ -1,45 +0,0 @@
|
|||
// Copyright (c) Tribufu. All Rights Reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
|
||||
namespace Tribufu.Serialization
|
||||
{
|
||||
public class ULongNullableStringConverter : JsonConverter<ulong?>
|
||||
{
|
||||
public override ulong? ReadJson(JsonReader reader, Type objectType, ulong? existingValue, bool hasExistingValue, JsonSerializer serializer)
|
||||
{
|
||||
if (reader.TokenType == JsonToken.Null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (reader.TokenType == JsonToken.String || reader.TokenType == JsonToken.Integer)
|
||||
{
|
||||
string value = reader.Value?.ToString();
|
||||
|
||||
if (string.IsNullOrWhiteSpace(value))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return ulong.Parse(value);
|
||||
}
|
||||
|
||||
throw new JsonSerializationException($"Unexpected token {reader.TokenType} when parsing ulong?.");
|
||||
}
|
||||
|
||||
public override void WriteJson(JsonWriter writer, ulong? value, JsonSerializer serializer)
|
||||
{
|
||||
if (value.HasValue)
|
||||
{
|
||||
writer.WriteValue(value.Value.ToString());
|
||||
}
|
||||
else
|
||||
{
|
||||
writer.WriteNull();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue