本文整理汇总了C#中BsonDocument.ToList方法的典型用法代码示例。如果您正苦于以下问题:C# BsonDocument.ToList方法的具体用法?C# BsonDocument.ToList怎么用?C# BsonDocument.ToList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BsonDocument
的用法示例。
在下文中一共展示了BsonDocument.ToList方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReplaceResult
private void ReplaceResult(BsonDocument document, BsonValue result)
{
foreach (var element in document.ToList())
{
var value = element.Value;
if (value.IsString && value.AsString == "*result")
{
document[element.Name] = result;
}
}
}
示例2: ReplacePropertyPrefixes
void ReplacePropertyPrefixes(BsonDocument doc, string prefixToReplace, string replacement)
{
foreach (var property in doc.ToList())
{
if (property.Name.StartsWith(prefixToReplace))
{
doc.Remove(property.Name);
// since we know that it's most likely just about JSON.NET's $type property, we ensure that the replaced element gets to be first (which is required by JSON.NET)
doc.InsertAt(0, new BsonElement(replacement + property.Name.Substring(prefixToReplace.Length), property.Value));
}
if (property.Value.IsBsonDocument)
{
ReplacePropertyPrefixes(property.Value.AsBsonDocument, prefixToReplace, replacement);
continue;
}
if (property.Value.IsBsonArray)
{
foreach (var bsonValue in property.Value.AsBsonArray)
{
if (bsonValue.IsBsonDocument)
{
ReplacePropertyPrefixes(bsonValue.AsBsonDocument, prefixToReplace, replacement);
}
}
}
}
}
示例3: ReplaceActual
private void ReplaceActual(BsonDocument document, BsonDocument actual)
{
foreach (var element in document.ToList())
{
var value = element.Value;
if (value.IsString && value.AsString == "*actual")
{
document[element.Name] = actual[element.Name];
}
}
}