//public ItemInfo (Position item, )
        //{
            
        //}

        public void SetBaseInfo(Position item, SteamSchemaResponse steamSchema, Dictionary<string, double> steamItems)
        {
            ICollection<string> keys = steamSchema.Result.Qualities.Keys;
            var qualitiesDictionary = keys.ToDictionary(i => steamSchema.Result.Qualities[i]);

            var s = from pp in steamSchema.Result.Items where pp.Defindex == item.Defindex select pp.ItemName;
            _name = steamSchema.Result.QualityNames[qualitiesDictionary[item.Quality]] + " " + s.ToArray()[0];

            if (steamItems.ContainsKey(_name))
                AddPrices(steamItems[_name], steamItems[_name] * 0.87, "Steam Market");
            else
            {
                _name = "Strange " + _name;
                AddPrices(steamItems[_name], steamItems[_name] * 0.87, "Steam Market");
            }

            AddPrices(item.Price.Sell * k, item.Price.Buy * k, "TF2Mart");
        }
        private static void Main()
        {
            // Tf2Mart requests ------------------------------------------------------- //
            var tf2Mart = new List<Tf2MartResponse>();
            {
                var i = 0;
                do
                {
                    var postParameters = string.Format(Requests.Parameters.TF2_MART_POST_PARAMS, i);
                    var tf2MartResponse = Requests.Post(Requests.Parameters.TF2_MART_URI, postParameters);
                    tf2Mart.Add(Json.Decode<Tf2MartResponse>(tf2MartResponse));

                    Console.Write("\rЗагруженно {0} из {1}", i, tf2Mart[0].Max);
                    i++;
                } while (tf2Mart[0].Max != i - 1) ;
            }
            Console.WriteLine("\n--------------------\nEnd of tf2Mart requests");
            // ---------------------------------------------------------------------- //


            // SteamSchema request -------------------------------------------------- //
            var steamSchema = new SteamSchemaResponse();
            using (
                var ms =
                    new MemoryStream(
                        Encoding.UTF8.GetBytes(Requests.Get(Requests.Parameters.STEAM_SCHEMA_URI + "en").ReadToEnd())))
            {
                var ser = new DataContractJsonSerializer(steamSchema.GetType(),
                    new DataContractJsonSerializerSettings
                    {
                        UseSimpleDictionaryFormat = true
                    });
                steamSchema = ser.ReadObject(ms) as SteamSchemaResponse;
            }
            Console.WriteLine("\n--------------------\nEnd of SteamSchema request");
            // ---------------------------------------------------------------------- //


            // SteamItems forming --------------------------------------------------- //
            
            var steamItemsDictionary = new Dictionary<string, double>();
            {
                var i = 0;
                int totalCount;
                do
                {
                    var steamItem =
                        Json.Decode<SteamItemMarket>(
                            Requests.GetSteamItem(string.Format(Requests.Parameters.STEAM_MARKET_ITEM, i * 100)));
                    var doc = new HtmlDocument();
                    doc.LoadHtml(steamItem.results_html);
                    var priceCollection = doc.DocumentNode.SelectNodes("//*[@id]/div[1]/div[2]/span[1]/span[1]");
                    var nameCollection = doc.DocumentNode.SelectNodes("/a/div[1]/div[2]/span[1]");
                    var reg = new Regex(@"[^ pуб.]");
                    for (int k = 0; k < priceCollection.Count; k++)
                    {
                        var p = reg.Matches(priceCollection[k].InnerText).Cast<object>().Aggregate("", (current, j) => current + j);
                        steamItemsDictionary.Add(nameCollection[k].InnerText, double.Parse(p));
                    }

                    Console.Write("\rЗагруженно {0} из {1}", i * 100 + priceCollection.Count, steamItem.total_count);
                    totalCount = steamItem.total_count;
                    i++;
                } while (totalCount > i * 100);
            }
            // ---------------------------------------------------------------------- //


            // Item forming --------------------------------------------------------- //
            var itemInfos = new List<ItemInfo>();
            {
                var i = 0;
                foreach (var tf2 in tf2Mart)
                {
                    var j = 0;
                    foreach (var pos in tf2.Positions)
                    {
                        //Console.Write("\rЗагруженно {0} из {1}", i * 50 + j, (tf2.Max) * 50 + tf2Mart[tf2.Max].Positions.Count);
                        Console.Write("\rЗагруженно {0}", i * 50 + j);
                        var item = new ItemInfo();
                        item.SetBaseInfo(pos, steamSchema, steamItemsDictionary);
                        itemInfos.Add(item);
                        j++;
                    }
                    i++;
                }
            }
            // ---------------------------------------------------------------------- //


            Console.WriteLine("\n\n");


            // Profit printing ------------------------------------------------------ //
            foreach (var j in itemInfos.SelectMany(i => i.Trades))
            {
                if (j.TradeInfo.Equals("TF2Mart => Steam Market"))
                Console.WriteLine("Item {0,-55}  -- profit --  {1,15:### ###.00} руб. {2,-20} price {3}", j.Name, j.Profit, j.TradeInfo, j.BuyPrice);
            }
            // ---------------------------------------------------------------------- /



            //m;lkmm;




            Console.WriteLine("\nEnd of program \n(Print 1234)");
            string ps;
            do
            {
                ps = Console.ReadLine();
                ps = ps;
            } while (ps != null && !ps.Equals("1234"));

            Console.ReadKey();
        }