Browse Source

Merge pull request #23380 from abpframework/DisableAbpClassInterceptors

Add support for selective disabling of class interceptors
pull/23390/head
Engincan VESKE 1 year ago
committed by GitHub
parent
commit
18ef4c9a5f
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 3
      framework/src/Volo.Abp.Autofac/Autofac/Builder/AbpRegistrationBuilderExtensions.cs
  2. 6
      framework/src/Volo.Abp.Core/Microsoft/Extensions/DependencyInjection/ServiceCollectionRegistrationActionExtensions.cs
  3. 8
      framework/src/Volo.Abp.Core/Volo/Abp/DependencyInjection/ClassInterceptorsSelectorList.cs
  4. 8
      framework/src/Volo.Abp.Core/Volo/Abp/DependencyInjection/IClassInterceptorsSelectorList.cs
  5. 7
      framework/src/Volo.Abp.Core/Volo/Abp/DependencyInjection/ServiceRegistrationActionList.cs

3
framework/src/Volo.Abp.Autofac/Autofac/Builder/AbpRegistrationBuilderExtensions.cs

@ -126,7 +126,8 @@ public static class AbpRegistrationBuilderExtensions
}
else
{
if (serviceRegistrationActionList.IsClassInterceptorsDisabled)
if (serviceRegistrationActionList.IsClassInterceptorsDisabled ||
serviceRegistrationActionList.DisabledClassInterceptorsSelectors.Any(selector => selector.Predicate(serviceType)))
{
return registrationBuilder;
}

6
framework/src/Volo.Abp.Core/Microsoft/Extensions/DependencyInjection/ServiceCollectionRegistrationActionExtensions.cs

@ -1,4 +1,5 @@
using System;
using Volo.Abp;
using Volo.Abp.DependencyInjection;
namespace Microsoft.Extensions.DependencyInjection;
@ -39,6 +40,11 @@ public static class ServiceCollectionRegistrationActionExtensions
return GetOrCreateRegistrationActionList(services).IsClassInterceptorsDisabled;
}
public static void DisableAbpClassInterceptors(this IServiceCollection services, NamedTypeSelector selector)
{
GetOrCreateRegistrationActionList(services).DisabledClassInterceptorsSelectors.Add(selector);
}
// OnExposing
public static void OnExposing(this IServiceCollection services, Action<IOnServiceExposingContext> exposeAction)

8
framework/src/Volo.Abp.Core/Volo/Abp/DependencyInjection/ClassInterceptorsSelectorList.cs

@ -0,0 +1,8 @@
using System.Collections.Generic;
namespace Volo.Abp.DependencyInjection;
public class ClassInterceptorsSelectorList : List<NamedTypeSelector>, IClassInterceptorsSelectorList
{
}

8
framework/src/Volo.Abp.Core/Volo/Abp/DependencyInjection/IClassInterceptorsSelectorList.cs

@ -0,0 +1,8 @@
using System.Collections.Generic;
namespace Volo.Abp.DependencyInjection;
public interface IClassInterceptorsSelectorList : IList<NamedTypeSelector>
{
}

7
framework/src/Volo.Abp.Core/Volo/Abp/DependencyInjection/ServiceRegistrationActionList.cs

@ -6,4 +6,11 @@ namespace Volo.Abp.DependencyInjection;
public class ServiceRegistrationActionList : List<Action<IOnServiceRegistredContext>>
{
public bool IsClassInterceptorsDisabled { get; set; }
public IClassInterceptorsSelectorList DisabledClassInterceptorsSelectors { get; }
public ServiceRegistrationActionList()
{
DisabledClassInterceptorsSelectors = new ClassInterceptorsSelectorList();
}
}

Loading…
Cancel
Save