public abstract WriteSymbol ( string value ) : void | ||
value | string | The symbol. |
리턴 | void |
/// <summary> /// Serializes an object to a BsonWriter. /// </summary> /// <param name="bsonWriter">The BsonWriter.</param> /// <param name="nominalType">The nominal type.</param> /// <param name="value">The object.</param> /// <param name="options">The serialization options.</param> public override void Serialize( BsonWriter bsonWriter, Type nominalType, object value, IBsonSerializationOptions options) { if (value == null) { throw new ArgumentNullException("value"); } var symbol = (BsonSymbol)value; bsonWriter.WriteSymbol(symbol.Name); }
/// <summary> /// Serializes an object to a BsonWriter. /// </summary> /// <param name="bsonWriter">The BsonWriter.</param> /// <param name="nominalType">The nominal type.</param> /// <param name="value">The object.</param> /// <param name="options">The serialization options.</param> public override void Serialize( BsonWriter bsonWriter, Type nominalType, object value, IBsonSerializationOptions options) { if (value == null) { bsonWriter.WriteNull(); } else { var stringValue = (string)value; var representationSerializationOptions = EnsureSerializationOptions<RepresentationSerializationOptions>(options); switch (representationSerializationOptions.Representation) { case BsonType.ObjectId: var id = ObjectId.Parse(stringValue); bsonWriter.WriteObjectId(id.Timestamp, id.Machine, id.Pid, id.Increment); break; case BsonType.String: bsonWriter.WriteString(stringValue); break; case BsonType.Symbol: bsonWriter.WriteSymbol(stringValue); break; default: var message = string.Format("'{0}' is not a valid String representation.", representationSerializationOptions.Representation); throw new BsonSerializationException(message); } } }
/// <summary> /// Serializes an object to a BsonWriter. /// </summary> /// <param name="bsonWriter">The BsonWriter.</param> /// <param name="nominalType">The nominal type.</param> /// <param name="value">The object.</param> /// <param name="options">The serialization options.</param> public override void Serialize( BsonWriter bsonWriter, Type nominalType, object value, IBsonSerializationOptions options) { if (value == null) { bsonWriter.WriteNull(); } else { var stringValue = (string)value; var representation = (options == null) ? BsonType.String : ((RepresentationSerializationOptions)options).Representation; switch (representation) { case BsonType.ObjectId: var id = ObjectId.Parse(stringValue); bsonWriter.WriteObjectId(id.Timestamp, id.Machine, id.Pid, id.Increment); break; case BsonType.String: bsonWriter.WriteString(stringValue); break; case BsonType.Symbol: bsonWriter.WriteSymbol(stringValue); break; default: throw new BsonInternalException("Unexpected representation."); } } }
/// <summary> /// Serializes an object to a BsonWriter. /// </summary> /// <param name="bsonWriter">The BsonWriter.</param> /// <param name="nominalType">The nominal type.</param> /// <param name="value">The object.</param> /// <param name="options">The serialization options.</param> public override void Serialize( BsonWriter bsonWriter, Type nominalType, object value, IBsonSerializationOptions options ) { if (value == null) { bsonWriter.WriteNull(); } else { var symbol = (BsonSymbol) value; var representation = (options == null) ? BsonType.Symbol : ((RepresentationSerializationOptions) options).Representation; switch (representation) { case BsonType.String: bsonWriter.WriteString(symbol.Name); break; case BsonType.Symbol: bsonWriter.WriteSymbol(symbol.Name); break; default: var message = string.Format("'{0}' is not a valid BsonSymbol value.", representation); throw new BsonSerializationException(message); } } }
public override void Serialize( BsonWriter bsonWriter, Type nominalType, object value, bool serializeIdFirst ) { if (value == null) { bsonWriter.WriteNull(); } else { bsonWriter.WriteSymbol(((BsonSymbol) value).Name); } }