本文整理匯總了C#中MongoDB.Bson.BsonDocumentWrapper.AddRange方法的典型用法代碼示例。如果您正苦於以下問題:C# BsonDocumentWrapper.AddRange方法的具體用法?C# BsonDocumentWrapper.AddRange怎麽用?C# BsonDocumentWrapper.AddRange使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類MongoDB.Bson.BsonDocumentWrapper
的用法示例。
在下文中一共展示了BsonDocumentWrapper.AddRange方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: 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]);
}
示例2: 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]);
}
示例3: 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]);
}