File size: 1,150 Bytes
fab29d7 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
using System.Text.Json.Nodes;
namespace VersOne.Epub.Test.Integration.JsonUtils.Serializers
{
internal class PropertySerializer
{
private readonly Func<object, JsonSerializationContext, JsonNode?> serializer;
public PropertySerializer(string typePropertyName, string jsonPropertyName, Func<object, JsonSerializationContext, JsonNode?> serializer,
bool skipPropertyIfValueIsNull, bool obtainCustomSerializer)
{
TypePropertyName = typePropertyName;
JsonPropertyName = jsonPropertyName;
this.serializer = serializer;
SkipPropertyIfValueIsNull = skipPropertyIfValueIsNull;
ObtainCustomSerializer = obtainCustomSerializer;
}
public string TypePropertyName { get; }
public string JsonPropertyName { get; }
public bool SkipPropertyIfValueIsNull { get; }
public bool ObtainCustomSerializer { get; }
public JsonNode? Serialize(object propertyValue, JsonSerializationContext jsonSerializationContext)
{
return serializer(propertyValue, jsonSerializationContext);
}
}
}
|