Browse Source

Merge pull request #10582 from abpframework/maliming/autofac

Upgrade Autofac to latest.
pull/10588/head
liangshiwei 5 years ago
committed by GitHub
parent
commit
af35f2d6d8
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      framework/src/Volo.Abp.Autofac/Autofac/Extensions/DependencyInjection/AutofacRegistration.cs
  2. 4
      framework/src/Volo.Abp.Autofac/Volo.Abp.Autofac.csproj
  3. 43
      framework/src/Volo.Abp.Autofac/Volo/Abp/Autofac/AbpAutofacConstructorFinder.cs

4
framework/src/Volo.Abp.Autofac/Autofac/Extensions/DependencyInjection/AutofacRegistration.cs

@ -24,12 +24,10 @@
// OTHER DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Reflection;
using Autofac.Builder;
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.Autofac;
using Volo.Abp;
using Volo.Abp.Modularity;
@ -189,7 +187,6 @@ namespace Autofac.Extensions.DependencyInjection
.RegisterGeneric(descriptor.ImplementationType)
.As(descriptor.ServiceType)
.ConfigureLifecycle(descriptor.Lifetime, lifetimeScopeTagForSingletons)
.FindConstructorsWith(new AbpAutofacConstructorFinder())
.ConfigureAbpConventions(moduleContainer, registrationActionList);
}
else
@ -198,7 +195,6 @@ namespace Autofac.Extensions.DependencyInjection
.RegisterType(descriptor.ImplementationType)
.As(descriptor.ServiceType)
.ConfigureLifecycle(descriptor.Lifetime, lifetimeScopeTagForSingletons)
.FindConstructorsWith(new AbpAutofacConstructorFinder())
.ConfigureAbpConventions(moduleContainer, registrationActionList);
}
}

4
framework/src/Volo.Abp.Autofac/Volo.Abp.Autofac.csproj

@ -15,8 +15,8 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Autofac" Version="6.2.0" />
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="7.1.0" />
<PackageReference Include="Autofac" Version="6.3.0" />
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="7.2.0" />
<PackageReference Include="Autofac.Extras.DynamicProxy" Version="6.0.0" />
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="$(MicrosoftPackageVersion)" />
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="$(MicrosoftPackageVersion)" />

43
framework/src/Volo.Abp.Autofac/Volo/Abp/Autofac/AbpAutofacConstructorFinder.cs

@ -1,43 +0,0 @@
using System;
using System.Collections.Concurrent;
using System.Reflection;
using Autofac.Core.Activators.Reflection;
namespace Volo.Abp.Autofac
{
public class AbpAutofacConstructorFinder : IConstructorFinder
{
private const BindingFlags DeclaredOnlyPublicFlags = BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly; //Remove static constructor, BindingFlags.Static
private readonly Func<Type, ConstructorInfo[]> _finder;
private static readonly ConcurrentDictionary<Type, ConstructorInfo[]> DefaultPublicConstructorsCache = new ConcurrentDictionary<Type, ConstructorInfo[]>();
public AbpAutofacConstructorFinder()
: this(GetDefaultPublicConstructors)
{
}
public AbpAutofacConstructorFinder(Func<Type, ConstructorInfo[]> finder)
{
_finder = finder ?? throw new ArgumentNullException(nameof(finder));
}
public ConstructorInfo[] FindConstructors(Type targetType)
{
return _finder(targetType);
}
private static ConstructorInfo[] GetDefaultPublicConstructors(Type type)
{
var retval = DefaultPublicConstructorsCache.GetOrAdd(type, t => t.GetConstructors(DeclaredOnlyPublicFlags));
if (retval.Length == 0)
{
throw new NoConstructorsFoundException(type);
}
return retval;
}
}
}
Loading…
Cancel
Save