Support multiple interceptors together
aditnryn opened this issue · comments
Is your feature request related to a problem? Please describe.
Add support for invoking two or more interceptors.
Describe the solution you'd like
Replace SetInterceptor
on IConfigurator
with AddInterceptor
method that allows chaining of interceptors.
Describe alternatives you've considered
Today, one can create the class ChainedInterceptor
that delegates to multiple interceptors to circumvent this feature gap.
class ChainedInterceptor(params ICommandInterceptor[] interceptors) : ICommandInterceptor
{
public void Intercept(CommandContext context, CommandSettings settings)
{
foreach (var interceptor in interceptors)
{
interceptor.Intercept(context, settings);
}
}
}
I'm interested in having library support for interceptor chaining.
Additional context
I'll be happy to contribute code to close this feature request. However, I'm not sure how to achieve this feature request without causing backward-incompatible changes to either the IConfigurator
or the ICommandAppSettings
interface.
Wouldn't it be better if we allowed multiple interceptors to be registered instead of a single one?
Yes, that's the intention of the feature request too. The SetInterceptor
method can be deprecated in favour of an AddInterceptor
method on the IConfigurator
interface IMO.