Browse Source

Merge two AssemblyHelper classes.

pull/96/head
Halil İbrahim Kalkan 9 years ago
parent
commit
1834cb251c
  1. 4
      src/Volo.Abp/Microsoft/Extensions/DependencyInjection/ServiceCollectionRegistrationActionExtensions.cs
  2. 15
      src/Volo.Abp/Volo/Abp/Reflection/AssemblyHelper.cs
  3. 15
      src/Volo.Abp/Volo/Abp/Reflection/TypeFinder.cs
  4. 2
      src/Volo.Abp/Volo/DependencyInjection/ConventionalRegistrarBase.cs
  5. 21
      src/Volo.Abp/Volo/Internal/AssemblyHelper.cs

4
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<IOnServiceRegistredContext> registrationAction)
{
GetOrCreateRegistrationActionList(services).Add(registrationAction);
@ -27,6 +29,8 @@ namespace Microsoft.Extensions.DependencyInjection
return actionList;
}
// OnExposing
public static void OnExposing(this IServiceCollection services, Action<IOnServiceExposingContext> exposeAction)
{
GetOrCreateExposingList(services).Add(exposeAction);

15
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<Type> GetAllTypes(Assembly assembly)
{
try
{
return assembly.GetTypes();
}
catch (ReflectionTypeLoadException ex)
{
return ex.Types;
}
}
}
}

15
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;
}

2
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
{

21
src/Volo.Abp/Volo/Internal/AssemblyHelper.cs

@ -1,21 +0,0 @@
using System;
using System.Collections.Generic;
using System.Reflection;
namespace Volo.Internal
{
internal static class AssemblyHelper
{
public static IReadOnlyList<Type> GetAllTypes(Assembly assembly)
{
try
{
return assembly.GetTypes();
}
catch (ReflectionTypeLoadException ex)
{
return ex.Types;
}
}
}
}
Loading…
Cancel
Save