CSMongo.Bson.BsonDocument.ToBsonByteArray C# (CSharp) Method

ToBsonByteArray() public method

Renders the bytes required to create a document
public ToBsonByteArray ( ) : byte[]
return byte[]
        public override byte[] ToBsonByteArray()
        {
            //create the default size
            DynamicStream stream = new DynamicStream(5);

            //generate the bytes
            stream.InsertAt(4, base.ToBsonByteArray());

            //update the length
            stream.WriteAt(0, BsonTranslator.AsInt32(stream.Length));

            //and return the bytes to use
            return stream.ToArray();
        }

Usage Example

Example #1
0
        /// <summary>
        /// Generates the message to send
        /// </summary>
        protected override void GenerateBody(DynamicStream stream)
        {
            BsonDocument document = new BsonDocument();
            document["db.users.remove()"] = 1.0;

            stream.Append(document.ToBsonByteArray());
        }
All Usage Examples Of CSMongo.Bson.BsonDocument::ToBsonByteArray