public string GetKernelVersion(IServerConnectionService connectionService)
        {
            var command = commandProvider.GetCommand(nameof(GetKernelVersion));

            command.ThrowError = true;
            var result = connectionService.ExecuteCommand(command);

            return(result.Result);
        }
Esempio n. 2
0
        public ulong GetActiveMemory(IServerConnectionService connectionService)
        {
            var command = commandProvider.GetCommand(nameof(GetActiveMemory));

            command.ThrowError = true;
            var result = connectionService.ExecuteCommand(command);

            return(ulong.Parse(result.Result));
        }
        public IPAddress GetIPAddress(IServerConnectionService connectionService)
        {
            var command = commandProvider.GetCommand(nameof(GetIPAddress));

            command.ThrowError = true;
            var result = connectionService.ExecuteCommand(command);

            return(IPAddress.Parse(result.Result));
        }
Esempio n. 4
0
        public Move GetCommand(Player Player)
        {
            var input = CommandProvider.GetCommand(Player);

            var toks = input.Split(null).Select(s => s.Trim()).Where(s => s.Length > 0);

            if (!toks.Any())
            {
                return(null);
            }

            var verb = toks.First();

            var action = Player.FindAction(verb);

            if (action == null)
            {
                return(null);
            }

            if (!action.TryParse(toks.Skip(1), Player, out Move choice))
            {
                return(null);
            }
            else
            {
                return(choice);
            }
        }
Esempio n. 5
0
        public async Task Run()
        {
            var input = string.Empty;

            while (input != "q")
            {
                WriteLine("Welcome to the ShopDemo");
                WriteLine("Enter 'b' to list the product categories.");
                WriteLine("Enter 'c' to list the featured products.");
                WriteLine("Enter 'd' to list the products by their categories.");
                WriteLine("Enter 'q' to quit the program.");

                WriteLine("Please enter an option:");

                input = ReadKey().KeyChar.ToString().ToLower();

                Clear();

                var provider = _commandProvider.GetCommand(input);

                if (provider != null)
                {
                    await provider.ExecuteAsync().ConfigureAwait(false);
                }

                WriteLine();
            }
        }
Esempio n. 6
0
        //private void Pubsub_OnRewardRedeemed(object sender, TwitchLib.PubSub.Events.OnRewardRedeemedArgs e)
        //{
        //    var player = playerProvider.Get(e.Login);
        //    var cmd = commandProvider.GetCommand(player, e.RewardTitle, e.RewardPrompt);
        //    if (cmd != null)
        //        commandHandler.HandleAsync(this, cmd);
        //}

        private void Pubsub_OnChannelPointsRewardRedeemed(object sender, TwitchLib.PubSub.Events.OnChannelPointsRewardRedeemedArgs e)
        {
            var player = playerProvider.Get(e.RewardRedeemed.Redemption.User.Login);
            var cmd    = commandProvider.GetCommand(player, e.RewardRedeemed.Redemption.Reward.Title, e.RewardRedeemed.Redemption.Reward.Prompt);

            if (cmd != null)
            {
                commandHandler.HandleAsync(this, cmd);
            }
        }
Esempio n. 7
0
        public async Task <object?[]> Run()
        {
            var results = new List <object?>();
            var args    = new ParserState(Operands.ToArray());


            if (!args.HasCurrent)
            {
                var defaultCommand = DefaultCommand;
                if (defaultCommand == null)
                {
                    throw new NoDefaultCommandException();
                }
                else
                {
                    results.Add(await defaultCommand.Invoke(args, valueParser));
                }
            }
            else
            {
                while (args.HasCurrent)
                {
                    var defaultCommand = DefaultCommand;
                    if (defaultCommand == null)
                    {
                        var commandName = args.Current;
                        var command     = commandProvider.GetCommand(commandName);
                        args.Consume();
                        results.Add(await command.Invoke(args, valueParser));
                    }
                    else
                    {
                        // command found?
                        // execute
                        // else
                        // execute default command
                        // check that is consumes arguments to avoid endless loop

                        var commandName = args.Current;
                        var command     = commandProvider.TryGetCommand(commandName);
                        if (command is { })
        public void GetCommand_WhenCalled_ReturnsCorrectCommand(string key, Type expectedcommand)
        {
            var result = _commandProvider.GetCommand(key);

            Assert.AreEqual(result.GetType(), expectedcommand);
        }