示例#1
0
        private async Task <Dictionary <string, TransforfField> > AsyncGetCryptoOrderBook(Dictionary <string, TransformInfo> arg)
        {
            return(await new Task <Dictionary <string, TransforfField> >(delegate
            {
                CryptoCoinIdenteti Ident = new CryptoCoinIdenteti();
                Ident.Field.Data = Ident.Field.Data.Where(d => arg.ContainsKey(d.Symbol)).ToList();
                Dictionary <string, TransforfField> temp = new Dictionary <string, TransforfField>();
                foreach (var i in Ident.Field.Data)
                {
                    string site = String.Format("https://www.cryptopia.co.nz/api/GetMarketOrders/{0}/10", i.Id);
                    HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(site);
                    WebResponse resp = req.GetResponse();

                    using (StreamReader stream = new StreamReader(
                               resp.GetResponseStream(), Encoding.UTF8))
                    {
                        string str = stream.ReadToEnd();
                        var res = JsonConvert.DeserializeObject <Field>(str);

                        if (res.Success == true)
                        {
                            temp.Add(i.Label, new TransforfField(res.Data.Sell, res.Data.Buy));
                        }
                    }
                }
                return temp;
            }));
        }
示例#2
0
        private Dictionary <string, TransforfField> GetCryptoOrderBook()
        {
            CryptoCoinIdenteti Ident = new CryptoCoinIdenteti();
            Dictionary <string, TransforfField> temp = new Dictionary <string, TransforfField>();

            foreach (var i in Ident.Field.Data)
            {
                string         site = String.Format("https://www.cryptopia.co.nz/api/GetMarketOrders/{0}/10", i.Id);
                HttpWebRequest req  = (HttpWebRequest)HttpWebRequest.Create(site);
                WebResponse    resp = req.GetResponse();

                using (StreamReader stream = new StreamReader(
                           resp.GetResponseStream(), Encoding.UTF8))
                {
                    string str = stream.ReadToEnd();
                    var    res = JsonConvert.DeserializeObject <Field>(str);

                    if (res.Success == true)
                    {
                        temp.Add(i.Label, new TransforfField(res.Data.Sell, res.Data.Buy));
                    }
                }
            }
            return(temp);
        }