-
Notifications
You must be signed in to change notification settings - Fork 14
Open
Labels
ImprovementNew feature or requestNew feature or request
Description
Describe the suggested improvement
Is your improvement related to a problem? Please describe.
Many .NET configuration APIs accept an Action so that the configuration options don't need to be explicitly created. I'd suggest in this case doing the same
Describe the suggested solution
Change the method to allow for lambda configuration so it's not outside of the scope of the use call.
Also adding the extension to IServiceCollection will IConfiguration options to be easily used instead of other hackery caused by the v2 implementation of this package.
public static IServiceCollection UseNServiceBus(
this IServiceCollection services,
string endpointName,
Action<EndpointConfiguration> configuration)
{
Argument.ThrowIfNull(endpointName);
Argument.ThrowIfNull(configuration);
var endpointConfiguration = new EndpointConfiguration(endpointName);
configuration.Invoke(configuration);
//do whatever the current method does with the endpointConfiguraiton
// this allows for services method chaining
return services;
}
Describe alternatives you've considered
AddNserviceBus instead of UseNServiceBus. Add is the typical nomenclature for "adding services" via dependency injection. "Use" is typically used in the middleware portion of the pipeline after the App is built. That would be a larger change to consider though.
Additional Context
No response
Metadata
Metadata
Assignees
Labels
ImprovementNew feature or requestNew feature or request