當前位置: 首頁>>代碼示例>>C#>>正文


C# BsonBuffer.WriteBytes方法代碼示例

本文整理匯總了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);
 }
開發者ID:einaregilsson,項目名稱:mongo-csharp-driver,代碼行數:7,代碼來源:MongoInsertMessage.cs

示例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);
        }
開發者ID:purplecow,項目名稱:mongo-csharp-driver,代碼行數:54,代碼來源:BsonDocumentTests.cs

示例3: AddOverflow

        // private methods
        private void AddOverflow(BsonBuffer buffer, byte[] serializedDocument)
        {
            buffer.WriteBytes(serializedDocument);

            _batchCount++;
            _batchLength = buffer.Position - _batchStartPosition;
        }
開發者ID:Khosrow-Azizi,項目名稱:MasterExperimentV2,代碼行數:8,代碼來源:MongoInsertMessage.cs


注:本文中的MongoDB.Bson.IO.BsonBuffer.WriteBytes方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。