/// <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)
            {
                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 symbol = (BsonSymbol)value;
                var representationSerializationOptions = EnsureSerializationOptions<RepresentationSerializationOptions>(options);

                switch (representationSerializationOptions.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 representation.", representationSerializationOptions.Representation);
                        throw new BsonSerializationException(message);
                }
            }
        }