本文整理汇总了C#中Newtonsoft.Json.Linq.JObject.OfType方法的典型用法代码示例。如果您正苦于以下问题:C# JObject.OfType方法的具体用法?C# JObject.OfType怎么用?C# JObject.OfType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Newtonsoft.Json.Linq.JObject
的用法示例。
在下文中一共展示了JObject.OfType方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReadFromJObject
public static TransHistory ReadFromJObject(JObject o)
{
return new TransHistory
{
List =
o.OfType<KeyValuePair<string, JToken>>()
.ToDictionary(a => int.Parse(a.Key), a => Transaction.ReadFromJObject(a.Value as JObject))
};
}
示例2: ReadFromJObject
public static OrderList ReadFromJObject(JObject o)
{
var orderList = new OrderList() {List = new Dictionary<int, Order>()};
var res = o.Properties().ToList();
foreach (JProperty property in res)
{
orderList.List.Add(int.Parse(property.Name), Order.ReadFromJObject(property.Value as JObject));
}
return orderList;
return new OrderList() {
List = o.OfType<KeyValuePair<string, JToken>>().ToDictionary(item => int.Parse(item.Key), item => Order.ReadFromJObject(item.Value as JObject))
};
}
示例3: Stat
private IEnumerable<StatEntry> Stat(JObject hitTable)
{
var table = hitTable
.OfType<JProperty>()
.Select(x => new
{
Database = x.Name,
Hashes = ((JObject)x.Value).OfType<JProperty>()
.Select(y => new
{
Hash = GetStateHash(y.Name),
LastHitTime = new DateTime((long)y.Value)
})
}).SelectMany(x => x.Hashes, (d, h) => new
{
d.Database,
h.Hash,
h.LastHitTime
});
var root = GetCachesDir(false);
var dirs = root.Exists ? root.EnumerateDirectories() : Enumerable.Empty<DirectoryInfo>();
var files = dirs
.Select(x => new
{
Database = x.Name,
Files = x.EnumerateFiles()
}).SelectMany(x => x.Files, (d, f) => new
{
d.Database,
Hash = GetStateHash(f.Name),
FilePath = f.FullName
});
var lookTable = table.ToLookup(x => new { x.Database, x.Hash });
var lookFiles = files.ToLookup(x => new { x.Database, x.Hash });
var keys = lookTable.ToHashSet(x => x.Key);
keys.UnionWith(lookFiles.Select(x => x.Key));
return
from key in keys
let tLook = lookTable[key]
let fLook = lookFiles[key]
from t in tLook.DefaultIfEmpty()
from f in fLook.DefaultIfEmpty()
select new StatEntry(key.Database, key.Hash, f == null ? null : f.FilePath, t == null ? (DateTime?)null : t.LastHitTime);
}
示例4: ReadFromJObject
public static TradeHistory ReadFromJObject(JObject o) {
return new TradeHistory() {
List = o.OfType<KeyValuePair<string, JToken>>().ToDictionary(item => int.Parse(item.Key), item => Trade.ReadFromJObject(item.Value as JObject))
};
}
示例5: ReadFromJObject
public static OrderList ReadFromJObject(JObject o) {
return new OrderList() {
List = o.OfType<KeyValuePair<string, JToken>>().ToDictionary(item => int.Parse(item.Key), item => Order.ReadFromJObject(item.Value as JObject))
};
}