Skip to content

Commit

Permalink
housekeeping: Handle the DateTimeOffset cause where BSON data is alre…
Browse files Browse the repository at this point in the history
…ady in Date. (#450)

Handle backwards compatibility case where data is already stored in the old format in the BSON format.
  • Loading branch information
glennawatson committed Dec 27, 2018
1 parent 573bc62 commit 9598aeb
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Akavache.Core/JsonDateTimeOffsetTickConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ public override void WriteJson(JsonWriter writer, object value, JsonSerializer s

public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
{
if (reader.TokenType == JsonToken.Date)
{
return (DateTimeOffset)reader.Value;
}

var data = serializer.Deserialize<DateTimeOffsetData>(reader);

if (data == null)
Expand Down

0 comments on commit 9598aeb

Please sign in to comment.