本文整理匯總了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))
};
}