diff --git a/src/Scrutor/ServiceCollectionExtensions.Decoration.cs b/src/Scrutor/ServiceCollectionExtensions.Decoration.cs index 189ffad7..3905d606 100644 --- a/src/Scrutor/ServiceCollectionExtensions.Decoration.cs +++ b/src/Scrutor/ServiceCollectionExtensions.Decoration.cs @@ -25,6 +25,23 @@ public static IServiceCollection Decorate(this IServiceCol return services.Decorate(typeof(TService), typeof(TDecorator)); } + /// + /// Decorates all registered services of type + /// using the specified type . + /// + /// The services to add to. + /// The of the service. + /// If no service of the type has been registered. + /// If the argument is null. + public static IServiceCollection DecorateKeyed(this IServiceCollection services, string serviceKey) + where TDecorator : TService + { + Preconditions.NotNull(services, nameof(services)); + Preconditions.NotNull(serviceKey, nameof(serviceKey)); + + return services.Decorate(DecorationStrategy.WithType(typeof(TService), serviceKey, typeof(TDecorator))); + } + /// /// Decorates all registered services of type /// using the specified type .