Ejemplo n.º 1
0
        private static async Task <List <SupportedCoin> > ParseResponseAsync(string response)
        {
            List <SupportedCoin> CoinList = new List <SupportedCoin>();
            SupportedCoin        ToAdd    = new SupportedCoin();

            using (JsonTextReader jtr = new JsonTextReader(new StringReader(response)))
            {
                while (await jtr.ReadAsync().ConfigureAwait(false))
                {
                    if (jtr.TokenType.ToString() == "StartObject")
                    {
                        if (!string.IsNullOrEmpty(ToAdd.Name))
                        {
                            CoinList.Add(ToAdd);
                        }
                        ToAdd = new SupportedCoin();
                        continue;
                    }
                    if (jtr.Value != null)
                    {
                        if (jtr.Value.ToString() == "name")
                        {
                            await jtr.ReadAsync().ConfigureAwait(false);

                            ToAdd.Name = jtr.Value.ToString();
                        }
                        else if (jtr.Value.ToString() == "symbol")
                        {
                            await jtr.ReadAsync().ConfigureAwait(false);

                            ToAdd.Symbol = jtr.Value.ToString();
                        }
                        else if (jtr.Value.ToString() == "image")
                        {
                            await jtr.ReadAsync().ConfigureAwait(false);

                            ToAdd.ImageLink = jtr.Value.ToString();
                        }
                        else if (jtr.Value.ToString() == "status")
                        {
                            await jtr.ReadAsync().ConfigureAwait(false);

                            ToAdd.Status = jtr.Value.ToString() == "available" ? CoinStatuses.Available : CoinStatuses.Unavailable;
                        }
                        else
                        {
                            continue;
                        }
                    }
                }
            }
            if (!string.IsNullOrEmpty(ToAdd.Name))
            {
                CoinList.Add(ToAdd);
            }

            return(CoinList);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Generates a list of all TradingPairs supported by ShapeShift.
        /// </summary>
        /// <returns>A List of TradingPairs.</returns>
        internal static async Task <List <TradingPair> > GetAllPairsAsync()
        {
            //Initialize an empty List of TradingPairs
            List <TradingPair> PairList = new List <TradingPair>();
            //Generate a List of all SupportedCoins
            List <SupportedCoin> CoinList = await SupportedCoin.GetCoinsAsync().ConfigureAwait(false);

            //Loop through all SupportedCoins
            foreach (SupportedCoin Coin1 in CoinList)
            {
                //Check if coin is available for Shifting
                if (Coin1.Status == CoinStatuses.Available)
                {
                    //Loop through all SupportedCoins again for generating all TradingPairs
                    foreach (SupportedCoin Coin2 in CoinList)
                    {
                        //Check if both coins are not the same and both coins are available to Shift
                        if (Coin1 != Coin2 && Coin2.Status == CoinStatuses.Available)
                        {
                            //Create new TradingPair object and assign values
                            TradingPair NewPair = new TradingPair();
                            NewPair.Ticker1 = Coin1.Symbol;
                            NewPair.Ticker2 = Coin2.Symbol;
                            NewPair.Pair    = string.Format("{0}_{1}", Coin1.Symbol, Coin2.Symbol);
                            //Add new TradingPair object to List of TradingPairs
                            PairList.Add(NewPair);
                        }
                        else
                        {
                            continue;
                        }
                    }
                }
                else
                {
                    continue;
                }
            }
            //Return complete TradingPair List
            return(PairList);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Provides information on all currencies supported by ShapeShift.
 /// </summary>
 /// <returns>List of all supported currencies.</returns>
 public static async Task <List <SupportedCoin> > GetAllCoinsAsync() =>
 await SupportedCoin.GetCoinsAsync().ConfigureAwait(false);
Ejemplo n.º 4
0
 /// <summary>
 /// Provides information on a specific currency supported by ShapeShift.
 /// </summary>
 /// <param name="Symbol">Ticker symbol of currency.</param>
 /// <returns>Information on specific supported currency.</returns>
 public static async Task <SupportedCoin> GetCoinAsync(string Symbol) =>
 await SupportedCoin.GetCoinAsync(Symbol).ConfigureAwait(false);