From 80dea6b5a5e82ac3aac160b1fa380aa95845e147 Mon Sep 17 00:00:00 2001
From: Vladimir Portyanikhin <86243191+portyanikhin@users.noreply.github.com>
Date: Mon, 23 Dec 2024 12:54:59 +0300
Subject: [PATCH] The `IsDecorated` method has been made public
---
.../ServiceCollectionExtensions.Decoration.cs | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
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);
}