/// <inheritdoc />
        public override void Serialize(
            BsonSerializationContext context,
            BsonSerializationArgs args,
            ReportingPeriod value)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            if (value == null)
            {
                context.Writer.WriteNull();
            }
            else
            {
                var persistenceModel = new ReportingPeriodPersistenceModel
                {
                    Start = value.Start.SerializeToSortableString(),
                    End   = value.End.SerializeToSortableString(),
                };

                ReportingPeriodPersistenceModel.Serializer.Serialize(context, persistenceModel);
            }
        }
Пример #2
0
        /// <inheritdoc />
        public override void Serialize(
            BsonSerializationContext context,
            BsonSerializationArgs args,
            TValue value)
        {
            new { context }.Must().NotBeNull();

            if (value == null)
            {
                context.Writer.WriteNull();
            }
            else
            {
                var persistenceModel = new ReportingPeriodPersistenceModel
                {
                    Start = value.Start.SerializeToSortableString(),
                    End   = value.End.SerializeToSortableString(),
                };

                ReportingPeriodPersistenceModel.Serializer.Serialize(context, persistenceModel);
            }
        }