Exemple #1
0
 private async Task InvokeAsync(Command command, CommandParameterBuilder builder, object instance)
 {
     if (!command.Method.ReturnType.IsLike <Task>())
     {
         command.Method.Invoke(instance, builder.Build());
     }
     else if (command.Method.Invoke(instance, builder.Build()) is Task task)
     {
         await task;
     }
 }
Exemple #2
0
        public async Task InvokeAsync(string input)
        {
            if (string.IsNullOrWhiteSpace(input))
            {
                return;
            }

            if (FindCommand(input) is var command && command == null)
            {
                throw new CommandNotFoundException();
            }

            var instance = _services.GetService(command.Type);
            var builder  = new CommandParameterBuilder(command);

            builder.TryAddValue(input);
            builder.TryAddOptions(input);

            await InvokeAsync(command, builder, instance);
        }