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);
|
||||
}
|
||||
}
|
||||
}
|
30
Client/Infrastructure/Parsers/Converters/RawConverter.cs
Normal file
30
Client/Infrastructure/Parsers/Converters/RawConverter.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
|
||||
namespace Client.Infrastructure.Parsers.Converters
|
||||
{
|
||||
public class RawConverter : JsonConverter
|
||||
{
|
||||
public override bool CanConvert(Type objectType)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public override object? ReadJson(JsonReader reader, Type objectType, object? existingValue, JsonSerializer serializer)
|
||||
{
|
||||
if (reader.TokenType == JsonToken.Null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var raw = JRaw.Create(reader);
|
||||
return raw.ToString();
|
||||
}
|
||||
|
||||
public override void WriteJson(JsonWriter writer, object? value, JsonSerializer serializer)
|
||||
{
|
||||
writer.WriteRawValue(value == null ? null : (string)value);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user