Exemplo n.º 1
0
        private static Task <int> Execute(
            CommandTree leaf,
            CommandTree tree,
            CommandContext context,
            ITypeResolver resolver)
        {
            // Create the command and the settings.
            var settings = leaf.CreateSettings(resolver);

            // Bind the command tree against the settings.
            CommandBinder.Bind(tree, ref settings, resolver);

            // 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));
        }