Table of Contents

Class TimeSpanSerializer

Namespace
MongoDB.Bson.Serialization.Serializers
Assembly
MongoDB.Bson.dll

Represents a serializer for Timespans.

public class TimeSpanSerializer : StructSerializerBase<TimeSpan>, IBsonSerializer<TimeSpan>, IBsonSerializer, IRepresentationConfigurable<TimeSpanSerializer>, IRepresentationConfigurable, IHasRepresentationSerializer
Inheritance
TimeSpanSerializer
Implements
Inherited Members
Extension Methods

Constructors

TimeSpanSerializer()

Initializes a new instance of the TimeSpanSerializer class.

public TimeSpanSerializer()

TimeSpanSerializer(BsonType)

Initializes a new instance of the TimeSpanSerializer class.

public TimeSpanSerializer(BsonType representation)

Parameters

representation BsonType

The representation.

TimeSpanSerializer(BsonType, TimeSpanUnits)

Initializes a new instance of the TimeSpanSerializer class.

public TimeSpanSerializer(BsonType representation, TimeSpanUnits units)

Parameters

representation BsonType

The representation.

units TimeSpanUnits

The units.

Properties

Representation

Gets the representation.

public BsonType Representation { get; }

Property Value

BsonType

The representation.

Units

Gets the units.

public TimeSpanUnits Units { get; }

Property Value

TimeSpanUnits

The units.

Methods

Deserialize(BsonDeserializationContext, BsonDeserializationArgs)

Deserializes a value.

public override TimeSpan Deserialize(BsonDeserializationContext context, BsonDeserializationArgs args)

Parameters

context BsonDeserializationContext

The deserialization context.

args BsonDeserializationArgs

The deserialization args.

Returns

TimeSpan

A deserialized value.

Serialize(BsonSerializationContext, BsonSerializationArgs, TimeSpan)

Serializes a value.

public override void Serialize(BsonSerializationContext context, BsonSerializationArgs args, TimeSpan value)

Parameters

context BsonSerializationContext

The serialization context.

args BsonSerializationArgs

The serialization args.

value TimeSpan

The object.

WithRepresentation(BsonType)

Returns a serializer that has been reconfigured with the specified representation.

public TimeSpanSerializer WithRepresentation(BsonType representation)

Parameters

representation BsonType

The representation.

Returns

TimeSpanSerializer

The reconfigured serializer.

WithRepresentation(BsonType, TimeSpanUnits)

Returns a serializer that has been reconfigured with the specified representation and units.

public TimeSpanSerializer WithRepresentation(BsonType representation, TimeSpanUnits units)

Parameters

representation BsonType

The representation.

units TimeSpanUnits

The units.

Returns

TimeSpanSerializer

The reconfigured serializer.