MongoDB.Bson.IO.BsonBinaryWriter.WriteRegularExpression C# (CSharp) Method

WriteRegularExpression() public method

Writes a BSON regular expression to the writer.
public WriteRegularExpression ( BsonRegularExpression regex ) : void
regex BsonRegularExpression A BsonRegularExpression.
return void
        public override void WriteRegularExpression(BsonRegularExpression regex)
        {
            if (Disposed) { throw new ObjectDisposedException("BsonBinaryWriter"); }
            if (State != BsonWriterState.Value)
            {
                ThrowInvalidState("WriteRegularExpression", BsonWriterState.Value);
            }

            _buffer.WriteByte((byte)BsonType.RegularExpression);
            WriteNameHelper();
            _buffer.WriteCString(_binaryWriterSettings.Encoding, regex.Pattern);
            _buffer.WriteCString(_binaryWriterSettings.Encoding, regex.Options);

            State = GetNextState();
        }