当前位置: 首页>>代码示例>>C#>>正文


C# IBsonReader.ReadEndDocument方法代码示例

本文整理汇总了C#中IBsonReader.ReadEndDocument方法的典型用法代码示例。如果您正苦于以下问题:C# IBsonReader.ReadEndDocument方法的具体用法?C# IBsonReader.ReadEndDocument怎么用?C# IBsonReader.ReadEndDocument使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IBsonReader的用法示例。


在下文中一共展示了IBsonReader.ReadEndDocument方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestNestedDocument

 public void TestNestedDocument()
 {
     var json = "{ \"a\" : { \"b\" : 1, \"c\" : 2 } }";
     using (_bsonReader = new JsonReader(json))
     {
         Assert.Equal(BsonType.Document, _bsonReader.ReadBsonType());
         _bsonReader.ReadStartDocument();
         Assert.Equal(BsonType.Document, _bsonReader.ReadBsonType());
         Assert.Equal("a", _bsonReader.ReadName());
         _bsonReader.ReadStartDocument();
         Assert.Equal("b", _bsonReader.ReadName());
         Assert.Equal(1, _bsonReader.ReadInt32());
         Assert.Equal("c", _bsonReader.ReadName());
         Assert.Equal(2, _bsonReader.ReadInt32());
         _bsonReader.ReadEndDocument();
         _bsonReader.ReadEndDocument();
         Assert.Equal(BsonReaderState.Initial, _bsonReader.State);
     }
     Assert.Equal(json, BsonSerializer.Deserialize<BsonDocument>(json).ToJson());
 }
开发者ID:mfidemraizer,项目名称:mongo-csharp-driver,代码行数:20,代码来源:JsonReaderTests.cs

示例2: TestJavaScriptWithScope

 public void TestJavaScriptWithScope()
 {
     string json = "{ \"$code\" : \"function f() { return n; }\", \"$scope\" : { \"n\" : 1 } }";
     using (_bsonReader = new JsonReader(json))
     {
         Assert.Equal(BsonType.JavaScriptWithScope, _bsonReader.ReadBsonType());
         Assert.Equal("function f() { return n; }", _bsonReader.ReadJavaScriptWithScope());
         _bsonReader.ReadStartDocument();
         Assert.Equal(BsonType.Int32, _bsonReader.ReadBsonType());
         Assert.Equal("n", _bsonReader.ReadName());
         Assert.Equal(1, _bsonReader.ReadInt32());
         _bsonReader.ReadEndDocument();
         Assert.Equal(BsonReaderState.Initial, _bsonReader.State);
     }
     Assert.Equal(json, BsonSerializer.Deserialize<BsonJavaScriptWithScope>(json).ToJson());
 }
开发者ID:mfidemraizer,项目名称:mongo-csharp-driver,代码行数:16,代码来源:JsonReaderTests.cs

示例3: TestDocumentTwoElements

 public void TestDocumentTwoElements()
 {
     var json = "{ \"x\" : 1, \"y\" : 2 }";
     using (_bsonReader = new JsonReader(json))
     {
         Assert.Equal(BsonType.Document, _bsonReader.ReadBsonType());
         _bsonReader.ReadStartDocument();
         Assert.Equal(BsonType.Int32, _bsonReader.ReadBsonType());
         Assert.Equal("x", _bsonReader.ReadName());
         Assert.Equal(1, _bsonReader.ReadInt32());
         Assert.Equal(BsonType.Int32, _bsonReader.ReadBsonType());
         Assert.Equal("y", _bsonReader.ReadName());
         Assert.Equal(2, _bsonReader.ReadInt32());
         Assert.Equal(BsonType.EndOfDocument, _bsonReader.ReadBsonType());
         _bsonReader.ReadEndDocument();
         Assert.Equal(BsonReaderState.Initial, _bsonReader.State);
     }
     Assert.Equal(json, BsonSerializer.Deserialize<BsonDocument>(json).ToJson());
 }
开发者ID:mfidemraizer,项目名称:mongo-csharp-driver,代码行数:19,代码来源:JsonReaderTests.cs

示例4: TestDocumentEmpty

 public void TestDocumentEmpty()
 {
     var json = "{ }";
     using (_bsonReader = new JsonReader(json))
     {
         Assert.Equal(BsonType.Document, _bsonReader.ReadBsonType());
         _bsonReader.ReadStartDocument();
         Assert.Equal(BsonType.EndOfDocument, _bsonReader.ReadBsonType());
         _bsonReader.ReadEndDocument();
         Assert.Equal(BsonReaderState.Initial, _bsonReader.State);
     }
     Assert.Equal(json, BsonSerializer.Deserialize<BsonDocument>(json).ToJson());
 }
开发者ID:mfidemraizer,项目名称:mongo-csharp-driver,代码行数:13,代码来源:JsonReaderTests.cs

示例5: TestBookmark

        public void TestBookmark()
        {
            var json = "{ \"x\" : 1, \"y\" : 2 }";
            using (_bsonReader = new JsonReader(json))
            {
                // do everything twice returning to bookmark in between
                var bookmark = _bsonReader.GetBookmark();
                Assert.Equal(BsonType.Document, _bsonReader.ReadBsonType());
                _bsonReader.ReturnToBookmark(bookmark);
                Assert.Equal(BsonType.Document, _bsonReader.ReadBsonType());

                bookmark = _bsonReader.GetBookmark();
                _bsonReader.ReadStartDocument();
                _bsonReader.ReturnToBookmark(bookmark);
                _bsonReader.ReadStartDocument();

                bookmark = _bsonReader.GetBookmark();
                Assert.Equal(BsonType.Int32, _bsonReader.ReadBsonType());
                _bsonReader.ReturnToBookmark(bookmark);
                Assert.Equal(BsonType.Int32, _bsonReader.ReadBsonType());

                bookmark = _bsonReader.GetBookmark();
                Assert.Equal("x", _bsonReader.ReadName());
                _bsonReader.ReturnToBookmark(bookmark);
                Assert.Equal("x", _bsonReader.ReadName());

                bookmark = _bsonReader.GetBookmark();
                Assert.Equal(1, _bsonReader.ReadInt32());
                _bsonReader.ReturnToBookmark(bookmark);
                Assert.Equal(1, _bsonReader.ReadInt32());

                bookmark = _bsonReader.GetBookmark();
                Assert.Equal(BsonType.Int32, _bsonReader.ReadBsonType());
                _bsonReader.ReturnToBookmark(bookmark);
                Assert.Equal(BsonType.Int32, _bsonReader.ReadBsonType());

                bookmark = _bsonReader.GetBookmark();
                Assert.Equal("y", _bsonReader.ReadName());
                _bsonReader.ReturnToBookmark(bookmark);
                Assert.Equal("y", _bsonReader.ReadName());

                bookmark = _bsonReader.GetBookmark();
                Assert.Equal(2, _bsonReader.ReadInt32());
                _bsonReader.ReturnToBookmark(bookmark);
                Assert.Equal(2, _bsonReader.ReadInt32());

                bookmark = _bsonReader.GetBookmark();
                Assert.Equal(BsonType.EndOfDocument, _bsonReader.ReadBsonType());
                _bsonReader.ReturnToBookmark(bookmark);
                Assert.Equal(BsonType.EndOfDocument, _bsonReader.ReadBsonType());

                bookmark = _bsonReader.GetBookmark();
                _bsonReader.ReadEndDocument();
                _bsonReader.ReturnToBookmark(bookmark);
                _bsonReader.ReadEndDocument();

                Assert.Equal(BsonReaderState.Initial, _bsonReader.State);

            }
            Assert.Equal(json, BsonSerializer.Deserialize<BsonDocument>(json).ToJson());
        }
开发者ID:mfidemraizer,项目名称:mongo-csharp-driver,代码行数:61,代码来源:JsonReaderTests.cs


注:本文中的IBsonReader.ReadEndDocument方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。