Ejemplo n.º 1
0
 internal decimal GetPrice(string strCoin)
 {
     try
     {
         return(Math.Ceiling(decimal.Parse(StringManipulation.getBetween(strCoinMcap, @"<a href=""/currencies/" + strCoin + @"/#markets"" class=""price"" data-usd=""", @""" data-")) * 100) / 100);
     }
     catch (Exception ex)
     {
         System.Console.WriteLine(ex.ToString());
         return(0);
     }
 }
Ejemplo n.º 2
0
        internal async Task <List <coins> > getPricesAsync()     // string manipulation way of getting coin prices
        {
            string strcoin = "";
            char   c;
            int    count = -1;

            try
            {
                indexOfCoinPrice      = StringManipulation.AllIndexesOf(strCoinMcap, @"/#markets"" class=""price"" data-usd=");
                indexOfCirculatingSup = StringManipulation.AllIndexesOf(strCoinMcap, @"circulating-supply");

                foreach (var item in indexOfCoinPrice)
                {
                    coins coinToAdd = new coins("", 0);

                    c = strCoinMcap[item + count];
                    while (c != '/')
                    {
                        strcoin += c;
                        count--;
                        c = strCoinMcap[item + count];
                    }
                    strcoin        = StringManipulation.Reverse(strcoin);
                    coinToAdd.Name = strcoin;
                    await Task.Run(() => coinToAdd.Volume = getVolume(strcoin));

                    coinToAdd.Price       = GetPrice(strcoin);
                    coinToAdd.circulating = getCirculatingSuply(strcoin);
                    //coinToAdd.Marketcap = GetCoinMCap(coinToAdd);
                    strcoin = "";
                    count   = -1;
                    coins.Add(coinToAdd);
                }

                return(coins);
            }
            catch (Exception)
            {
                return(null);
            }
        }