public void SerializeProperty( BsonWriter bsonWriter, object obj, BsonPropertyMap propertyMap ) { var value = (BsonInt64) propertyMap.Getter(obj); if (value == null) { bsonWriter.WriteNull(propertyMap.ElementName); } else { bsonWriter.WriteInt64(propertyMap.ElementName, value.Value); } }
public void SerializeProperty( BsonWriter bsonWriter, object obj, BsonPropertyMap propertyMap ) { var value = (ulong) propertyMap.Getter(obj); if (propertyMap.UseCompactRepresentation) { bsonWriter.WriteInt64(propertyMap.ElementName, (long) value); } else { bsonWriter.WriteDocumentName(propertyMap.ElementName); bsonWriter.WriteStartDocument(); bsonWriter.WriteString("_t", typeof(ulong).FullName); bsonWriter.WriteInt64("v", (long) value); bsonWriter.WriteEndDocument(); } }
public void SerializeProperty( BsonWriter bsonWriter, object obj, BsonPropertyMap propertyMap ) { var value = (long) propertyMap.Getter(obj); bsonWriter.WriteInt64(propertyMap.ElementName, value); }
public void SerializeProperty( BsonWriter bsonWriter, object obj, BsonPropertyMap propertyMap ) { // note: the DateTime portion cannot be serialized as a BsonType.DateTime because it is NOT in UTC var value = (DateTimeOffset) propertyMap.Getter(obj); if (propertyMap.UseCompactRepresentation) { bsonWriter.WriteArrayName(propertyMap.ElementName); bsonWriter.WriteStartDocument(); bsonWriter.WriteInt64("0", value.DateTime.Ticks); bsonWriter.WriteInt64("1", value.Offset.Ticks); bsonWriter.WriteEndDocument(); } else { bsonWriter.WriteDocumentName(propertyMap.ElementName); bsonWriter.WriteStartDocument(); bsonWriter.WriteString("_t", typeof(DateTimeOffset).FullName); bsonWriter.WriteString("dt", value.DateTime.ToString("yyyy-MM-ddTHH:mm:ss.FFFFFFF")); // omit trailing zeros bsonWriter.WriteString("o", Regex.Replace(value.Offset.ToString(), ":00$", "")); // omit trailing zeros bsonWriter.WriteEndDocument(); } }