Esempio n. 1
0
        /// <summary>
        /// Serializes a value.
        /// </summary>
        /// <param name="context">The serialization context.</param>
        /// <param name="value">The value.</param>
        protected override void SerializeValue(BsonSerializationContext context, GeoJsonMultiPointCoordinates <TCoordinates> value)
        {
            var bsonWriter = context.Writer;

            bsonWriter.WriteStartArray();
            foreach (var position in value.Positions)
            {
                context.SerializeWithChildContext(_coordinatesSerializer, position);
            }
            bsonWriter.WriteEndArray();
        }
        // protected methods
        /// <summary>
        /// Deserializes a value.
        /// </summary>
        /// <param name="context">The deserialization context.</param>
        /// <param name="args">The deserialization args.</param>
        /// <returns>The value.</returns>
        protected override GeoJsonMultiPoint <TCoordinates> DeserializeValue(BsonDeserializationContext context, BsonDeserializationArgs args)
        {
            var geoJsonObjectArgs = new GeoJsonObjectArgs <TCoordinates>();
            GeoJsonMultiPointCoordinates <TCoordinates> coordinates = null;

            _helper.DeserializeMembers(context, (elementName, flag) =>
            {
                switch (flag)
                {
                case Flags.Coordinates: coordinates = DeserializeCoordinates(context); break;

                default: _helper.DeserializeBaseMember(context, elementName, flag, geoJsonObjectArgs); break;
                }
            });

            return(new GeoJsonMultiPoint <TCoordinates>(geoJsonObjectArgs, coordinates));
        }
 private void SerializeCoordinates(BsonWriter bsonWriter, GeoJsonMultiPointCoordinates <TCoordinates> coordinates)
 {
     bsonWriter.WriteName("coordinates");
     _coordinatesSerializer.Serialize(bsonWriter, typeof(GeoJsonMultiPointCoordinates <TCoordinates>), coordinates, null);
 }
 private void SerializeCoordinates(BsonSerializationContext context, GeoJsonMultiPointCoordinates <TCoordinates> coordinates)
 {
     context.Writer.WriteName("coordinates");
     _coordinatesSerializer.Serialize(context, coordinates);
 }