Skip to content

Commit

Permalink
added open generic support for decorator func
Browse files Browse the repository at this point in the history
  • Loading branch information
Kamil Zakiev committed Jun 6, 2019
1 parent 5df6b40 commit 1dff356
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/Scrutor/ServiceCollectionExtensions.Decoration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,16 @@ private static bool IsSameGenericType(Type t1, Type t2)
return t1.IsGenericType && t2.IsGenericType && t1.GetGenericTypeDefinition() == t2.GetGenericTypeDefinition();
}

private static IServiceCollection DecorateOpenGeneric(this IServiceCollection services, Type serviceType, Func<object, IServiceProvider, object> decorator)
{
if (services.TryDecorateOpenGeneric(serviceType, decorator))
{
return services;
}

throw new MissingTypeRegistrationException(serviceType);
}

private static bool TryDecorateOpenGeneric(this IServiceCollection services, Type serviceType, Type decoratorType)
{
bool TryDecorate(Type[] typeArguments)
Expand Down

0 comments on commit 1dff356

Please sign in to comment.