/// <summary> /// Writes a the bytes for a CS string in BSON format /// </summary> public static byte[] AsCString(string value) { var stream = new DynamicStream(); stream.Append(AsString(value)); stream.InsertAt(0, BitConverter.GetBytes(stream.Length)); return stream.ToArray(); }
/// <summary> /// Renders the bytes required to create a document /// </summary> 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(); }