Skip to content

Commit

Permalink
add Deserializer
Browse files Browse the repository at this point in the history
  • Loading branch information
felpasl committed Jul 31, 2023
1 parent 79256df commit ef7d69f
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion fruit-consumer-azurefunction/FruitMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
namespace Fruit.Consumer.AzureFunction
{

public class FruitMessage : ISerializer<FruitMessage>
public class FruitMessage : ISerializer<FruitMessage>, IDeserializer<FruitMessage>
{
public DateTime? now { get; set; }
public Fruit? fruit { get; set; }
Expand Down Expand Up @@ -41,6 +41,11 @@ public byte[] Serialize(FruitMessage data, SerializationContext context)
return ms.ToArray();
}
}

public FruitMessage Deserialize(ReadOnlySpan<byte> data, bool isNull, SerializationContext context)
{
return JsonConvert.DeserializeObject<FruitMessage>(Encoding.UTF8.GetString(data));
}
}
public class LowercaseContractResolver : DefaultContractResolver
{
Expand Down

0 comments on commit ef7d69f

Please sign in to comment.