当前位置: 首页>>代码示例>>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;未经允许,请勿转载。