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