Exemple #1
0
        private static Task <int> Execute(
            CommandTree leaf,
            CommandTree tree,
            CommandContext context,
            ITypeResolver resolver,
            IConfiguration configuration)
        {
            // Bind the command tree against the settings.
            var settings = CommandBinder.Bind(tree, leaf.Command.SettingsType, resolver);

            configuration.Settings.Interceptor?.Intercept(context, settings);

            // Create and validate the command.
            var command          = leaf.CreateCommand(resolver);
            var validationResult = command.Validate(context, settings);

            if (!validationResult.Successful)
            {
                throw RuntimeException.ValidationFailed(validationResult);
            }

            // Execute the command.
            return(command.Execute(context, settings));
        }