本文整理汇总了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;
}