Beispiel #1
0
        public bool HandleCommand(string[] input)
        {
            if (input.Count() >= 2)
            {
                var verb = input[1];

                bool add    = verb.Equals(CommandArguments.Add, StringComparison.OrdinalIgnoreCase);
                bool remove = verb.Equals(CommandArguments.Remove, StringComparison.OrdinalIgnoreCase);
                bool list   = verb.Equals(CommandArguments.List, StringComparison.OrdinalIgnoreCase);
                bool edit   = verb.Equals(CommandArguments.Edit, StringComparison.OrdinalIgnoreCase);

                if (list)
                {
                    var symbol = String.Empty;
                    if (input.Count() >= 3)
                    {
                        symbol = input[2];
                    }

                    HandlePoolListCommand(symbol);
                    return(true); //early exit
                }
                else if (remove)
                {
                    if (HandlePoolRemoveCommand(input))
                    {
                        return(true);
                    }
                }
                else if (edit)
                {
                    if ((input.Count() == 6) && HandlePoolEditCommand(input))
                    {
                        return(true);
                    }
                }
                else if (input.Count() >= 3)
                {
                    var symbol = input[2];

                    CoinApi.Data.CoinInformation coin = app.CoinApiInformation.SingleOrDefault(
                        c => c.Symbol.Equals(symbol, StringComparison.OrdinalIgnoreCase) ||
                        c.Symbol.ShortCoinSymbol().Equals(symbol, StringComparison.Ordinal));

                    if (coin == null)
                    {
                        notificationHandler(String.Format("Unknown coin: {0}", symbol));
                        return(true); //early exit
                    }
                    else if (input.Count() >= 4)
                    {
                        var url = input[3];

                        if (add && (input.Count() == 6))
                        {
                            var user = input[4];
                            var pass = input[5];

                            app.AddNewPool(coin, url, user, pass);
                            return(true); //early exit
                        }
                    }
                }
            }

            return(false);
        }