當前位置: 首頁>>代碼示例>>C#>>正文


C# JObject.OfType方法代碼示例

本文整理匯總了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))
     };
 }
開發者ID:pavasorn,項目名稱:RTSBitcoin,代碼行數:9,代碼來源:TransHistory.cs

示例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))
			};
		}
開發者ID:erdincay,項目名稱:bitcoinTradingFramework,代碼行數:15,代碼來源:OrderList.cs

示例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);
        }
開發者ID:aiedail92,項目名稱:DBBranchManager,代碼行數:47,代碼來源:CacheManager.cs

示例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))
			};
		}
開發者ID:erdincay,項目名稱:CoinTNet,代碼行數:5,代碼來源:TradeHistory.cs

示例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))
			};
		}
開發者ID:erdincay,項目名稱:easybot,代碼行數:5,代碼來源:OrderList.cs


注:本文中的Newtonsoft.Json.Linq.JObject.OfType方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。