/// <inheritdoc /> public ICommandBuilder BuildCommand(IModuleBuilder module, MethodInfo methodInfo) { module.NotNull(nameof(module)); methodInfo.NotNull(nameof(methodInfo)); if (!IsCommand(module, methodInfo)) { throw new ArgumentException(nameof(methodInfo), $"{methodInfo.Name} is not a valid command."); } var alias = GetAlias(methodInfo); var name = GetName(methodInfo, alias); var description = GetDescription(methodInfo); var remarks = GetRemarks(methodInfo); var priority = GetPriority(methodInfo); var runMode = GetRunMode(methodInfo); var ignoreExtraArgs = GetIgnoreExtraArgs(methodInfo); var argumentParserType = GetArgumentParserType(methodInfo); var attributes = GetAttributes(methodInfo); var preconditions = GetPreconditions(attributes); var enabled = GetEnabled(methodInfo); var isAsync = GetIsAsync(methodInfo); var asyncResultType = GetAsyncResultType(methodInfo, isAsync); var builder = new CommandBuilder() .WithMethodInfo(methodInfo) .WithName(name) .WithDescription(description) .WithRemarks(remarks) .WithPriority(priority) .WithRunMode(runMode) .WithIgnoreExtraArgs(ignoreExtraArgs) .WithArgumentParserType(argumentParserType) .WithAlias(alias) .WithEnabled(enabled) .WithAttributes(attributes) .WithPreconditions(preconditions) .WithModule(module) .WithIsAsync(isAsync) .WithAsyncResultType(asyncResultType); var executor = GetExecutor(module, builder); builder.WithExecutor(executor); var parameters = GetParameters(builder); builder.WithParameters(parameters); return(builder); }
private void Validate(IModuleBuilder builder) { builder.NotNull(nameof(builder)); builder.Type.NotNull(nameof(builder.Type)); builder.Name.NotNullOrWhiteSpace(nameof(builder.Name)); }