public static CommandSettings CreateSettings(CommandValueLookup lookup, Type settingsType, ITypeResolver resolver) { var settings = CreateSettings(resolver, settingsType); foreach (var (parameter, value) in lookup) { parameter.Property.SetValue(settings, value); } // Validate the settings. var validationResult = settings.Validate(); if (!validationResult.Successful) { throw CommandRuntimeException.ValidationFailed(validationResult); } return settings; }
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 CommandRuntimeException.ValidationFailed(validationResult); } // Execute the command. return(command.Execute(context, settings)); }