diff --git a/framework/src/Volo.Abp.Core/Volo/Abp/DependencyInjection/AutoRegistrationHelper.cs b/framework/src/Volo.Abp.Core/Volo/Abp/DependencyInjection/AutoRegistrationHelper.cs index dd8795855e..7d0ce0a39e 100644 --- a/framework/src/Volo.Abp.Core/Volo/Abp/DependencyInjection/AutoRegistrationHelper.cs +++ b/framework/src/Volo.Abp.Core/Volo/Abp/DependencyInjection/AutoRegistrationHelper.cs @@ -8,7 +8,7 @@ namespace Volo.Abp.DependencyInjection { public static class AutoRegistrationHelper { - public static IEnumerable GetExposedServices(IServiceCollection services, Type type) + public static List GetExposedServices(IServiceCollection services, Type type) { var typeInfo = type.GetTypeInfo(); @@ -23,10 +23,10 @@ namespace Volo.Abp.DependencyInjection return customExposedServices; } - return GetDefaultExposedServices(services, type); + return GetDefaultExposedServices(type); } - private static IEnumerable GetDefaultExposedServices(IServiceCollection services, Type type) + private static List GetDefaultExposedServices(Type type) { var serviceTypes = new List(); @@ -47,16 +47,6 @@ namespace Volo.Abp.DependencyInjection } } - var exposeActions = services.GetExposingActionList(); - if (exposeActions.Any()) - { - var args = new OnServiceExposingContext(type, serviceTypes); - foreach (var action in services.GetExposingActionList()) - { - action(args); - } - } - return serviceTypes; } } diff --git a/framework/src/Volo.Abp.Core/Volo/Abp/DependencyInjection/DefaultConventionalRegistrar.cs b/framework/src/Volo.Abp.Core/Volo/Abp/DependencyInjection/DefaultConventionalRegistrar.cs index 19740d6ab6..b76c37682d 100644 --- a/framework/src/Volo.Abp.Core/Volo/Abp/DependencyInjection/DefaultConventionalRegistrar.cs +++ b/framework/src/Volo.Abp.Core/Volo/Abp/DependencyInjection/DefaultConventionalRegistrar.cs @@ -1,4 +1,6 @@ using System; +using System.Collections.Generic; +using System.Linq; using System.Reflection; using JetBrains.Annotations; using Microsoft.Extensions.DependencyInjection; @@ -24,7 +26,11 @@ namespace Volo.Abp.DependencyInjection return; } - foreach (var serviceType in AutoRegistrationHelper.GetExposedServices(services, type)) + var serviceTypes = AutoRegistrationHelper.GetExposedServices(services, type); + + TriggerServiceExposing(services, type, serviceTypes); + + foreach (var serviceType in serviceTypes) { var serviceDescriptor = ServiceDescriptor.Describe(serviceType, type, lifeTime.Value); @@ -43,6 +49,19 @@ namespace Volo.Abp.DependencyInjection } } + protected virtual void TriggerServiceExposing(IServiceCollection services, Type type, List serviceTypes) + { + var exposeActions = services.GetExposingActionList(); + if (exposeActions.Any()) + { + var args = new OnServiceExposingContext(type, serviceTypes); + foreach (var action in exposeActions) + { + action(args); + } + } + } + protected virtual bool IsConventionalRegistrationDisabled(Type type) { return type.IsDefined(typeof(DisableConventionalRegistrationAttribute), true);