summaryrefslogtreecommitdiff
path: root/src/SMAPI.Web/Framework/Caching/UtcDateTimeOffsetSerializer.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/SMAPI.Web/Framework/Caching/UtcDateTimeOffsetSerializer.cs')
-rw-r--r--src/SMAPI.Web/Framework/Caching/UtcDateTimeOffsetSerializer.cs40
1 files changed, 0 insertions, 40 deletions
diff --git a/src/SMAPI.Web/Framework/Caching/UtcDateTimeOffsetSerializer.cs b/src/SMAPI.Web/Framework/Caching/UtcDateTimeOffsetSerializer.cs
deleted file mode 100644
index 6a103e37..00000000
--- a/src/SMAPI.Web/Framework/Caching/UtcDateTimeOffsetSerializer.cs
+++ /dev/null
@@ -1,40 +0,0 @@
-using System;
-using MongoDB.Bson;
-using MongoDB.Bson.Serialization;
-using MongoDB.Bson.Serialization.Serializers;
-
-namespace StardewModdingAPI.Web.Framework.Caching
-{
- /// <summary>Serializes <see cref="DateTimeOffset"/> to a UTC date field instead of the default array.</summary>
- public class UtcDateTimeOffsetSerializer : StructSerializerBase<DateTimeOffset>
- {
- /*********
- ** Fields
- *********/
- /// <summary>The underlying date serializer.</summary>
- private static readonly DateTimeSerializer DateTimeSerializer = new DateTimeSerializer(DateTimeKind.Utc, BsonType.DateTime);
-
-
- /*********
- ** Public methods
- *********/
- /// <summary>Deserializes a value.</summary>
- /// <param name="context">The deserialization context.</param>
- /// <param name="args">The deserialization args.</param>
- /// <returns>A deserialized value.</returns>
- public override DateTimeOffset Deserialize(BsonDeserializationContext context, BsonDeserializationArgs args)
- {
- DateTime date = UtcDateTimeOffsetSerializer.DateTimeSerializer.Deserialize(context, args);
- return new DateTimeOffset(date, TimeSpan.Zero);
- }
-
- /// <summary>Serializes a value.</summary>
- /// <param name="context">The serialization context.</param>
- /// <param name="args">The serialization args.</param>
- /// <param name="value">The object.</param>
- public override void Serialize(BsonSerializationContext context, BsonSerializationArgs args, DateTimeOffset value)
- {
- UtcDateTimeOffsetSerializer.DateTimeSerializer.Serialize(context, args, value.UtcDateTime);
- }
- }
-}