當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。