本文整理汇总了C#中RavenJObject.Where方法的典型用法代码示例。如果您正苦于以下问题:C# RavenJObject.Where方法的具体用法?C# RavenJObject.Where怎么用?C# RavenJObject.Where使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RavenJObject
的用法示例。
在下文中一共展示了RavenJObject.Where方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TrySimplifyingJson
private static void TrySimplifyingJson(RavenJObject jObject, JsonSerializer jsonSerializer)
{
if (jObject.Tag == null)
return;
var resolveContract = jsonSerializer.ContractResolver.ResolveContract(jObject.Tag.GetType());
var objectContract = resolveContract as JsonObjectContract;
if (objectContract == null)
return;
var deferredActions = new List<Action>();
foreach (var kvp in jObject)
{
var prop = kvp;
if (prop.Value == null)
continue;
var obj = prop.Value as RavenJObject;
if (obj == null)
continue;
var jsonProperty = objectContract.Properties.GetClosestMatchProperty(prop.Key);
if (ShouldSimplifyJsonBasedOnType(obj.Value<string>("$type"), jsonProperty) == false)
continue;
if (obj.ContainsKey("$values") == false)
{
deferredActions.Add(() => obj.Remove("$type"));
}
else
{
deferredActions.Add(() => jObject[prop.Key] = obj["$values"]);
}
}
foreach (var deferredAction in deferredActions)
{
deferredAction();
}
foreach (var prop in jObject.Where(prop => prop.Value != null))
{
switch (prop.Value.Type)
{
case JTokenType.Array:
foreach (var item in ((RavenJArray)prop.Value))
{
var ravenJObject = item as RavenJObject;
if (ravenJObject != null)
TrySimplifyingJson(ravenJObject, jsonSerializer);
}
break;
case JTokenType.Object:
TrySimplifyingJson((RavenJObject)prop.Value, jsonSerializer);
break;
}
}
}