public override void WriteJavaScriptWithScope(string code)
{
if (Disposed) { throw new ObjectDisposedException("BsonBinaryWriter"); }
if (State != BsonWriterState.Value)
{
ThrowInvalidState("WriteJavaScriptWithScope", BsonWriterState.Value);
}
_buffer.WriteByte((byte)BsonType.JavaScriptWithScope);
WriteNameHelper();
_context = new BsonBinaryWriterContext(_context, ContextType.JavaScriptWithScope, _buffer.Position);
_buffer.WriteInt32(0); // reserve space for size of JavaScript with scope value
_buffer.WriteString(_binaryWriterSettings.Encoding, code);
State = BsonWriterState.ScopeDocument;
}