예제 #1
0
        private static BitSkinsInventory ReadBitSkinsInventory(dynamic bitskinsInventoryD)
        {
            BitSkinsInventory bitSkinsInventory = null;

            if (bitskinsInventoryD != null)
            {
                dynamic items = bitskinsInventoryD.items;

                int?   totalItems = bitskinsInventoryD.total_items ?? null;
                double?TotalPrice = bitskinsInventoryD.total_price ?? null;

                List <BitSkinsInventoryItem> bitSkinsInventoryItems = new List <BitSkinsInventoryItem>();
                if (items != null)
                {
                    foreach (dynamic item in items)
                    {
                        BitSkinsInventoryItem bitSkinsInventoryItem = ReadBitskinsInventoryItem(item);
                        bitSkinsInventoryItems.Add(bitSkinsInventoryItem);
                    }
                }

                bitSkinsInventory = new BitSkinsInventory(totalItems, TotalPrice, bitSkinsInventoryItems);
            }

            return(bitSkinsInventory);
        }
예제 #2
0
        private static BitSkinsInventoryItem ReadBitskinsInventoryItem(dynamic item)
        {
            ReadInventoryItem(item, out string marketHashName, out double?suggestedPrice, out string itemType, out string image);
            int?   numberOfItems      = item.number_of_items ?? null;
            double?recentAveragePrice = (item.recent_sales_info == null) ? null : item.recent_sales_info.average_price;

            List <string> itemIds = new List <string>();

            foreach (dynamic itemId in item.item_ids)
            {
                itemIds.Add((string)itemId);
            }

            List <double> prices = new List <double>();

            foreach (dynamic price in item.prices)
            {
                prices.Add((double)price);
            }

            List <DateTime> createdAt = new List <DateTime>();

            foreach (dynamic date in item.created_at)
            {
                createdAt.Add(DateTimeExtension.FromUnixTime((long)date));
            }

            List <DateTime> updatedAt = new List <DateTime>();

            foreach (dynamic date in item.updated_at)
            {
                updatedAt.Add(DateTimeExtension.FromUnixTime((long)date));
            }

            List <DateTime> withdrawableAt = new List <DateTime>();

            foreach (dynamic date in item.withdrawable_at)
            {
                withdrawableAt.Add(DateTimeExtension.FromUnixTime((long)date));
            }

            BitSkinsInventoryItem bitSkinsInventoryItem = new BitSkinsInventoryItem(marketHashName, suggestedPrice, itemType, image,
                                                                                    numberOfItems, itemIds, prices, createdAt, updatedAt, withdrawableAt, recentAveragePrice);

            return(bitSkinsInventoryItem);
        }