Esempio n. 1
0
        public static List <Coin> GetCoinsInfoFromCoinsJson()
        {
            List <Coin> allCoins = new List <Coin>();

            /*
             * this has all coins "https://whattomine.com/calculators.json", but limited coin info , example
             * "id":74,"tag":"365","algorithm":"Keccak","lagging":true,"listed":false,"status":"No available stats","testing":false
             */
            string coinsUrl = "https://whattomine.com/coins.json";
            string response = InsighterService.GetHttpResponseText(coinsUrl);
            //  var values = CreaDev.Framework.Core.Utils.Serialization.DeSerialize<Dictionary<string, string>>(response);
            JObject json      = JObject.Parse(response);
            JToken  coinsjson = json.SelectToken("coins");

            foreach (JToken property in coinsjson.Children())
            {
                JProperty p        = property as JProperty;
                string    coinName = p.Name;
                string    values   = p.Value.ToString();
                WhatToMineCoinResponse whatToMineCoinResponse = CreaDev.Framework.Core.Utils.Serialization.DeSerialize <WhatToMineCoinResponse>(values);
                allCoins.Add(whatToMineCoinResponse.ToCoin(coinName));
            }

            return(allCoins);
        }
Esempio n. 2
0
        public static Coin GetCoinInfo(int coinWhatToMineId)
        {
            //Note that coins it could throw an error if not active!
            //{"errors":["Could not find active coin with id 74"]}
            try
            {
                string coinUrl  = $"https://whattomine.com/coins/{coinWhatToMineId}.json";
                string response = InsighterService.GetHttpResponseText(coinUrl);
                //  var values = CreaDev.Framework.Core.Utils.Serialization.DeSerialize<Dictionary<string, string>>(response);
                WhatToMineCoinResponse whatToMineCoinResponse = CreaDev.Framework.Core.Utils.Serialization.DeSerialize <WhatToMineCoinResponse>(response);

                return(whatToMineCoinResponse.ToCoin(whatToMineCoinResponse.name));
            }
            catch
            {
            }

            return(null);
        }