feat: create window client app
This commit is contained in:
33
Client/Infrastructure/Parsers/Converters/BooleanConverter.cs
Normal file
33
Client/Infrastructure/Parsers/Converters/BooleanConverter.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Client.Infrastructure.Parsers.Converters
|
||||
{
|
||||
public class BooleanConverter : JsonConverter
|
||||
{
|
||||
public override bool CanConvert(Type objectType)
|
||||
{
|
||||
return objectType == typeof(bool);
|
||||
}
|
||||
|
||||
public override object? ReadJson(JsonReader reader, Type objectType, object? existingValue, JsonSerializer serializer)
|
||||
{
|
||||
var value = reader.Value;
|
||||
if (value == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return value?.ToString()?.Trim('0') != "";
|
||||
}
|
||||
|
||||
public override void WriteJson(JsonWriter writer, object? value, JsonSerializer serializer)
|
||||
{
|
||||
writer.WriteRawValue(value == null ? null : (string)value);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user