本文整理匯總了C#中MongoDB.Bson.IO.BsonBuffer.WriteBytes方法的典型用法代碼示例。如果您正苦於以下問題:C# BsonBuffer.WriteBytes方法的具體用法?C# BsonBuffer.WriteBytes怎麽用?C# BsonBuffer.WriteBytes使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類MongoDB.Bson.IO.BsonBuffer
的用法示例。
在下文中一共展示了BsonBuffer.WriteBytes方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: ResetBatch
internal void ResetBatch(BsonBuffer buffer, byte[] lastDocument)
{
buffer.Position = _firstDocumentStartPosition;
buffer.Length = _firstDocumentStartPosition;
buffer.WriteBytes(lastDocument);
BackpatchMessageLength(buffer);
}
示例2: TestBenchmarks
public void TestBenchmarks()
{
int iterations;
DateTime start;
DateTime end;
TimeSpan duration;
iterations = 1;
start = DateTime.UtcNow;
for (int i = 0; i < iterations; i++)
{
// about 2.06 on my machine
//var doc = new BsonDocument {
// { "a", 1 },
// { "b", 2.0 },
// { "c", "hello" },
// { "d", DateTime.UtcNow },
// { "e", true }
// };
byte[] value = { 1, 2, 3, 4 };
MemoryStream stream = new MemoryStream();
for (int n = 0; n < 100000; n++)
{
stream.Write(value, 0, 4);
}
}
end = DateTime.UtcNow;
duration = end - start;
System.Diagnostics.Debug.WriteLine(duration);
start = DateTime.UtcNow;
for (int i = 0; i < iterations; i++)
{
// about 2.22 on my machine
//var doc = new BsonDocument {
// { "a", BsonValue.Create((object) 1) },
// { "b", BsonValue.Create((object) 2.0) },
// { "c", BsonValue.Create((object) "hello") },
// { "d", BsonValue.Create((object) DateTime.UtcNow) },
// { "e", BsonValue.Create((object) true) }
//};
byte[] value = { 1, 2, 3, 4 };
using (var buffer = new BsonBuffer())
{
for (int n = 0; n < 100000; n++)
{
buffer.WriteBytes(value);
}
}
}
end = DateTime.UtcNow;
duration = end - start;
System.Diagnostics.Debug.WriteLine(duration);
}
示例3: AddOverflow
// private methods
private void AddOverflow(BsonBuffer buffer, byte[] serializedDocument)
{
buffer.WriteBytes(serializedDocument);
_batchCount++;
_batchLength = buffer.Position - _batchStartPosition;
}