diff --git a/src/Volo.Abp/Microsoft/Extensions/DependencyInjection/ServiceCollectionRegistrationActionExtensions.cs b/src/Volo.Abp/Microsoft/Extensions/DependencyInjection/ServiceCollectionRegistrationActionExtensions.cs index 923b4c6c5f..ace9e81d7f 100644 --- a/src/Volo.Abp/Microsoft/Extensions/DependencyInjection/ServiceCollectionRegistrationActionExtensions.cs +++ b/src/Volo.Abp/Microsoft/Extensions/DependencyInjection/ServiceCollectionRegistrationActionExtensions.cs @@ -5,6 +5,8 @@ namespace Microsoft.Extensions.DependencyInjection { public static class ServiceCollectionRegistrationActionExtensions { + // OnRegistred + public static void OnRegistred(this IServiceCollection services, Action registrationAction) { GetOrCreateRegistrationActionList(services).Add(registrationAction); @@ -27,6 +29,8 @@ namespace Microsoft.Extensions.DependencyInjection return actionList; } + // OnExposing + public static void OnExposing(this IServiceCollection services, Action exposeAction) { GetOrCreateExposingList(services).Add(exposeAction); diff --git a/src/Volo.Abp/Volo/Abp/Reflection/AssemblyHelper.cs b/src/Volo.Abp/Volo/Abp/Reflection/AssemblyHelper.cs index 6247095b3d..d8edf93064 100644 --- a/src/Volo.Abp/Volo/Abp/Reflection/AssemblyHelper.cs +++ b/src/Volo.Abp/Volo/Abp/Reflection/AssemblyHelper.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.IO; using System.Linq; using System.Reflection; @@ -21,5 +22,17 @@ namespace Volo.Abp.Reflection .EnumerateFiles(folderPath, "*.*", searchOption) .Where(s => s.EndsWith(".dll") || s.EndsWith(".exe")); } + + public static IReadOnlyList GetAllTypes(Assembly assembly) + { + try + { + return assembly.GetTypes(); + } + catch (ReflectionTypeLoadException ex) + { + return ex.Types; + } + } } } diff --git a/src/Volo.Abp/Volo/Abp/Reflection/TypeFinder.cs b/src/Volo.Abp/Volo/Abp/Reflection/TypeFinder.cs index e1cfcb42bb..f70dffd7e9 100644 --- a/src/Volo.Abp/Volo/Abp/Reflection/TypeFinder.cs +++ b/src/Volo.Abp/Volo/Abp/Reflection/TypeFinder.cs @@ -1,11 +1,9 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Reflection; using System.Threading; using Microsoft.Extensions.Logging; using Volo.DependencyInjection; -using Volo.ExtensionMethods.Collections.Generic; namespace Volo.Abp.Reflection { @@ -35,18 +33,9 @@ namespace Volo.Abp.Reflection { try { - Type[] typesInThisAssembly; + var typesInThisAssembly = AssemblyHelper.GetAllTypes(assembly); - try - { - typesInThisAssembly = assembly.GetTypes(); - } - catch (ReflectionTypeLoadException ex) - { - typesInThisAssembly = ex.Types; - } - - if (typesInThisAssembly.IsNullOrEmpty()) + if (!typesInThisAssembly.Any()) { continue; } diff --git a/src/Volo.Abp/Volo/DependencyInjection/ConventionalRegistrarBase.cs b/src/Volo.Abp/Volo/DependencyInjection/ConventionalRegistrarBase.cs index e15c6037f0..e346a01ba3 100644 --- a/src/Volo.Abp/Volo/DependencyInjection/ConventionalRegistrarBase.cs +++ b/src/Volo.Abp/Volo/DependencyInjection/ConventionalRegistrarBase.cs @@ -2,7 +2,7 @@ using System.Linq; using System.Reflection; using Microsoft.Extensions.DependencyInjection; -using Volo.Internal; +using Volo.Abp.Reflection; namespace Volo.DependencyInjection { diff --git a/src/Volo.Abp/Volo/Internal/AssemblyHelper.cs b/src/Volo.Abp/Volo/Internal/AssemblyHelper.cs deleted file mode 100644 index bf82776566..0000000000 --- a/src/Volo.Abp/Volo/Internal/AssemblyHelper.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Reflection; - -namespace Volo.Internal -{ - internal static class AssemblyHelper - { - public static IReadOnlyList GetAllTypes(Assembly assembly) - { - try - { - return assembly.GetTypes(); - } - catch (ReflectionTypeLoadException ex) - { - return ex.Types; - } - } - } -} \ No newline at end of file