InsertAt() public method

Inserts a new byte at the specified index
public InsertAt ( int index, byte bytes ) : void
index int
bytes byte
return void
Beispiel #1
0
 /// <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();
 }
Beispiel #2
0
        /// <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();
        }