Skip to content

Commit

Permalink
The IsDecorated method has been made public
Browse files Browse the repository at this point in the history
  • Loading branch information
portyanikhin authored and khellang committed Dec 23, 2024
1 parent e77e0f2 commit 80dea6b
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/Scrutor/ServiceCollectionExtensions.Decoration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -275,6 +275,14 @@ public static bool TryDecorate(this IServiceCollection services, DecorationStrat
return decorated;
}

/// <summary>
/// Returns <c>true</c> if the specified service is decorated.
/// </summary>
/// <param name="descriptor">The service descriptor.</param>
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");
Expand All @@ -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);
}

0 comments on commit 80dea6b

Please sign in to comment.