diff --git a/src/Scrutor/ServiceCollectionExtensions.Decoration.cs b/src/Scrutor/ServiceCollectionExtensions.Decoration.cs
index ada3ab3e..a588beb8 100644
--- a/src/Scrutor/ServiceCollectionExtensions.Decoration.cs
+++ b/src/Scrutor/ServiceCollectionExtensions.Decoration.cs
@@ -252,7 +252,7 @@ public static bool TryDecorate(this IServiceCollection services, DecorationStrat
{
var serviceDescriptor = services[i];
- if (IsDecorated(serviceDescriptor) || !strategy.CanDecorate(serviceDescriptor))
+ if (serviceDescriptor.IsDecorated() || !strategy.CanDecorate(serviceDescriptor))
{
continue;
}
@@ -275,6 +275,14 @@ public static bool TryDecorate(this IServiceCollection services, DecorationStrat
return decorated;
}
+ ///
+ /// Returns true if the specified service is decorated.
+ ///
+ /// The service descriptor.
+ public static bool IsDecorated(this ServiceDescriptor descriptor) =>
+ descriptor.ServiceKey is string stringKey
+ && stringKey.EndsWith(DecoratedServiceKeySuffix, StringComparison.Ordinal);
+
private static string? GetDecoratorKey(ServiceDescriptor descriptor)
{
var uniqueId = Guid.NewGuid().ToString("n");
@@ -291,8 +299,4 @@ public static bool TryDecorate(this IServiceCollection services, DecorationStrat
return null;
}
-
- private static bool IsDecorated(ServiceDescriptor descriptor) =>
- descriptor.ServiceKey is string stringKey
- && stringKey.EndsWith(DecoratedServiceKeySuffix, StringComparison.Ordinal);
}