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


C# BsonDocumentWrapper.GetElement方法代码示例

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


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

示例1: TestAddNameValue

 public void TestAddNameValue()
 {
     var wrapper = new BsonDocumentWrapper(new BsonDocument());
     Assert.AreEqual(false, wrapper.IsMaterialized);
     wrapper.Add("x", 1);
     Assert.AreEqual(true, wrapper.IsMaterialized);
     Assert.AreEqual(1, wrapper.ElementCount);
     Assert.AreEqual("x", wrapper.GetElement(0).Name);
     Assert.AreEqual(new BsonInt32(1), wrapper[0]);
 }
开发者ID:rakesh-elevate,项目名称:mongo-csharp-driver,代码行数:10,代码来源:BsonDocumentWrapperTests.cs

示例2: TestAddNameValueFactoryWithCondition

        public void TestAddNameValueFactoryWithCondition()
        {
            var wrapper = new BsonDocumentWrapper(new BsonDocument());
            Assert.AreEqual(false, wrapper.IsMaterialized);
            wrapper.Add("x", () => 1, false);
            Assert.AreEqual(true, wrapper.IsMaterialized);
            Assert.AreEqual(0, wrapper.ElementCount);

            wrapper = new BsonDocumentWrapper(new BsonDocument());
            Assert.AreEqual(false, wrapper.IsMaterialized);
            wrapper.Add("x", () => 1, true);
            Assert.AreEqual(true, wrapper.IsMaterialized);
            Assert.AreEqual(1, wrapper.ElementCount);
            Assert.AreEqual("x", wrapper.GetElement(0).Name);
            Assert.AreEqual(new BsonInt32(1), wrapper[0]);
        }
开发者ID:rakesh-elevate,项目名称:mongo-csharp-driver,代码行数:16,代码来源:BsonDocumentWrapperTests.cs

示例3: TestSetElementByName

 public void TestSetElementByName()
 {
     var wrapper = new BsonDocumentWrapper(new BsonDocument("x", 1));
     Assert.AreEqual(false, wrapper.IsMaterialized);
     wrapper.SetElement(new BsonElement("x", 2));
     Assert.AreEqual(true, wrapper.IsMaterialized);
     Assert.AreEqual(1, wrapper.ElementCount);
     Assert.AreEqual("x", wrapper.GetElement(0).Name);
     Assert.AreEqual(new BsonInt32(2), wrapper[0]);
 }
开发者ID:rakesh-elevate,项目名称:mongo-csharp-driver,代码行数:10,代码来源:BsonDocumentWrapperTests.cs

示例4: TestRemoveElement

 public void TestRemoveElement()
 {
     var wrapper = new BsonDocumentWrapper(new BsonDocument { { "x", 1 }, { "y", 2 } });
     Assert.AreEqual(false, wrapper.IsMaterialized);
     wrapper.RemoveElement(new BsonElement("y", 2));
     Assert.AreEqual(true, wrapper.IsMaterialized);
     Assert.AreEqual(1, wrapper.ElementCount);
     Assert.AreEqual("x", wrapper.GetElement(0).Name);
     Assert.AreEqual(new BsonInt32(1), wrapper[0]);
 }
开发者ID:rakesh-elevate,项目名称:mongo-csharp-driver,代码行数:10,代码来源:BsonDocumentWrapperTests.cs

示例5: TestMergeOverwrite

 public void TestMergeOverwrite()
 {
     var wrapper = new BsonDocumentWrapper(new BsonDocument("x", 1));
     Assert.AreEqual(false, wrapper.IsMaterialized);
     var result = wrapper.Merge(new BsonDocument("x", 2), true);
     Assert.AreEqual(true, wrapper.IsMaterialized);
     Assert.AreSame(wrapper, result);
     Assert.AreEqual(1, wrapper.ElementCount);
     Assert.AreEqual("x", wrapper.GetElement(0).Name);
     Assert.AreEqual(new BsonInt32(2), wrapper[0]);
 }
开发者ID:rakesh-elevate,项目名称:mongo-csharp-driver,代码行数:11,代码来源:BsonDocumentWrapperTests.cs

示例6: TestIndexerByName

        public void TestIndexerByName()
        {
            var wrapper = new BsonDocumentWrapper(new BsonDocument("x", 1));
            Assert.AreEqual(false, wrapper.IsMaterialized);
            var value = wrapper["x"];
            Assert.AreEqual(true, wrapper.IsMaterialized);
            Assert.AreEqual(new BsonInt32(1), value);

            wrapper = new BsonDocumentWrapper(new BsonDocument());
            Assert.AreEqual(false, wrapper.IsMaterialized);
            wrapper["x"] = 1;
            Assert.AreEqual(true, wrapper.IsMaterialized);
            Assert.AreEqual(1, wrapper.ElementCount);
            Assert.AreEqual("x", wrapper.GetElement(0).Name);
            Assert.AreEqual(new BsonInt32(1), wrapper[0]);
        }
开发者ID:rakesh-elevate,项目名称:mongo-csharp-driver,代码行数:16,代码来源:BsonDocumentWrapperTests.cs

示例7: TestGetElementByName

 public void TestGetElementByName()
 {
     var wrapper = new BsonDocumentWrapper(new BsonDocument("x", 1));
     Assert.AreEqual(false, wrapper.IsMaterialized);
     var element = wrapper.GetElement("x");
     Assert.AreEqual(true, wrapper.IsMaterialized);
     Assert.AreEqual("x", element.Name);
     Assert.AreEqual(new BsonInt32(1), element.Value);
 }
开发者ID:rakesh-elevate,项目名称:mongo-csharp-driver,代码行数:9,代码来源:BsonDocumentWrapperTests.cs

示例8: TestAddRangeKeyValuePairs

        public void TestAddRangeKeyValuePairs()
        {
            var wrapper = new BsonDocumentWrapper(new BsonDocument());
            Assert.AreEqual(false, wrapper.IsMaterialized);
            wrapper.AddRange(new KeyValuePair<string, object>[0]);
            Assert.AreEqual(true, wrapper.IsMaterialized);
            Assert.AreEqual(0, wrapper.ElementCount);

            wrapper = new BsonDocumentWrapper(new BsonDocument());
            Assert.AreEqual(false, wrapper.IsMaterialized);
            wrapper.AddRange(new[] { new KeyValuePair<string, object>("x", 1) });
            Assert.AreEqual(true, wrapper.IsMaterialized);
            Assert.AreEqual(1, wrapper.ElementCount);
            Assert.AreEqual("x", wrapper.GetElement(0).Name);
            Assert.AreEqual(new BsonInt32(1), wrapper[0]);
        }
开发者ID:rakesh-elevate,项目名称:mongo-csharp-driver,代码行数:16,代码来源:BsonDocumentWrapperTests.cs

示例9: TestAddRangeIDictionary

        public void TestAddRangeIDictionary()
        {
            var wrapper = new BsonDocumentWrapper(new BsonDocument());
            Assert.AreEqual(false, wrapper.IsMaterialized);
            wrapper.AddRange(new Dictionary<string, object>());
            Assert.AreEqual(true, wrapper.IsMaterialized);
            Assert.AreEqual(0, wrapper.ElementCount);

            wrapper = new BsonDocumentWrapper(new BsonDocument());
            Assert.AreEqual(false, wrapper.IsMaterialized);
            wrapper.AddRange((IDictionary)(new Dictionary<string, object> { { "x", 1 } }));
            Assert.AreEqual(true, wrapper.IsMaterialized);
            Assert.AreEqual(1, wrapper.ElementCount);
            Assert.AreEqual("x", wrapper.GetElement(0).Name);
            Assert.AreEqual(new BsonInt32(1), wrapper[0]);
        }
开发者ID:rakesh-elevate,项目名称:mongo-csharp-driver,代码行数:16,代码来源:BsonDocumentWrapperTests.cs

示例10: TestAddRangeElements

        public void TestAddRangeElements()
        {
            var wrapper = new BsonDocumentWrapper(new BsonDocument());
            Assert.AreEqual(false, wrapper.IsMaterialized);
            wrapper.AddRange(new BsonElement[0]);
            Assert.AreEqual(true, wrapper.IsMaterialized);
            Assert.AreEqual(0, wrapper.ElementCount);

            wrapper = new BsonDocumentWrapper(new BsonDocument());
            Assert.AreEqual(false, wrapper.IsMaterialized);
            wrapper.AddRange(new[] { new BsonElement("x", 1) });
            Assert.AreEqual(true, wrapper.IsMaterialized);
            Assert.AreEqual(1, wrapper.ElementCount);
            Assert.AreEqual("x", wrapper.GetElement(0).Name);
            Assert.AreEqual(new BsonInt32(1), wrapper[0]);
        }
开发者ID:rakesh-elevate,项目名称:mongo-csharp-driver,代码行数:16,代码来源:BsonDocumentWrapperTests.cs

示例11: TestSetDocumentId

        public void TestSetDocumentId()
        {
#pragma warning disable 618
            var wrapper = new BsonDocumentWrapper(new BsonDocument("_id", 1));
            Assert.AreEqual(false, wrapper.IsMaterialized);
            wrapper.SetDocumentId(new BsonInt32(2));
            Assert.AreEqual(true, wrapper.IsMaterialized);
            Assert.AreEqual(1, wrapper.ElementCount);
            Assert.AreEqual("_id", wrapper.GetElement(0).Name);
            Assert.AreEqual(new BsonInt32(2), wrapper[0]);
#pragma warning restore
        }
开发者ID:niemyjski,项目名称:mongo-csharp-driver,代码行数:12,代码来源:BsonDocumentWrapperTests.cs


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