本文整理匯總了C#中MongoDB.Bson.IO.BsonBuffer.WriteByte方法的典型用法代碼示例。如果您正苦於以下問題:C# BsonBuffer.WriteByte方法的具體用法?C# BsonBuffer.WriteByte怎麽用?C# BsonBuffer.WriteByte使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類MongoDB.Bson.IO.BsonBuffer
的用法示例。
在下文中一共展示了BsonBuffer.WriteByte方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: WriteRawBsonArray
/// <summary>
/// Writes a raw BSON array.
/// </summary>
/// <param name="slice">The byte buffer containing the raw BSON array.</param>
public virtual void WriteRawBsonArray(IByteBuffer slice)
{
// overridden in BsonBinaryWriter
using (var bsonBuffer = new BsonBuffer())
{
BsonArray array;
// wrap the array in a fake document so we can deserialize it
var arrayLength = slice.Length;
var documentLength = arrayLength + 8;
bsonBuffer.WriteInt32(documentLength);
bsonBuffer.WriteByte((byte)BsonType.Array);
bsonBuffer.WriteByte((byte)'x');
bsonBuffer.WriteByte((byte)0);
bsonBuffer.ByteBuffer.WriteBytes(slice);
bsonBuffer.WriteByte((byte)0);
bsonBuffer.Position = 0;
using (var bsonReader = new BsonBinaryReader(bsonBuffer, true, BsonBinaryReaderSettings.Defaults))
{
bsonReader.ReadStartDocument();
bsonReader.ReadName("x");
array = (BsonArray)BsonArraySerializer.Instance.Deserialize(bsonReader, typeof(BsonArray), null);
bsonReader.ReadEndDocument();
}
BsonArraySerializer.Instance.Serialize(this, typeof(BsonArray), array, null);
}
}