Пример #1
0
        private static List <MarketItem> ReadMarketItems(string result)
        {
            dynamic responseServerD = JsonConvert.DeserializeObject(result);
            dynamic itemsD          = responseServerD.data.items;

            List <MarketItem> marketItems = new List <MarketItem>();

            if (itemsD != null)
            {
                foreach (dynamic item in itemsD)
                {
                    MarketItem marketItem = ReadMarketItem(item);
                    marketItems.Add(marketItem);
                }
            }

            return(marketItems);
        }
Пример #2
0
        private static MarketItem ReadMarketItem(dynamic item)
        {
            string   marketHashName     = item.market_hash_name ?? null;
            int?     totalItems         = item.total_items ?? null;
            double?  lowestPrice        = item.lowest_price ?? null;
            double?  highestPrice       = item.highest_price ?? null;
            double?  cumulativePrice    = item.cumulative_price ?? null;
            double?  recentAveragePrice = (item.recent_sales_info == null) ? null : item.recent_sales_info.average_price;
            DateTime?updatedAt          = null;

            if (item.updated_at != null)
            {
                updatedAt = DateTimeExtension.FromUnixTime((long)item.updated_at);
            }

            MarketItem marketItem = new MarketItem(marketHashName, totalItems, lowestPrice,
                                                   highestPrice, cumulativePrice, recentAveragePrice, updatedAt);

            return(marketItem);
        }