/// <summary> /// Provides the same conventions as using <see cref="McMaster.Extensions.CommandLineUtils.ConventionBuilderExtensions.UseDefaultConventions"/>, /// but with an additional external service provider. /// </summary> /// <param name="builder">The convention builder.</param> /// <param name="additionalServices">Additional services that should be passed to the service provider.</param> public static IConventionBuilder UseDefaultConventionsWithServices(this IConventionBuilder builder, IServiceProvider additionalServices) => builder.UseAttributes() .SetAppNameFromEntryAssembly() .SetRemainingArgsPropertyOnModel() .SetSubcommandPropertyOnModel() .SetParentPropertyOnModel() .UseOnExecuteMethodFromModel() .UseOnValidateMethodFromModel() .UseOnValidationErrorMethodFromModel() .UseConstructorInjection(additionalServices);
/// <summary> /// Applies a collection of default conventions, such as applying options in attributes /// on the model type, /// </summary> /// <returns>The builder.</returns> public static IConventionBuilder UseDefaultConventions(this IConventionBuilder builder) { if (builder == null) { throw new ArgumentNullException(nameof(builder)); } return(builder .UseAttributes() .SetAppNameFromEntryAssembly() .SetRemainingArgsPropertyOnModel() .SetSubcommandPropertyOnModel() .SetParentPropertyOnModel() .UseOnExecuteMethodFromModel() .UseOnValidationErrorMethodFromModel()); }