Browse Source

Add support for selective disabling of class interceptors

pull/23380/head
maliming 1 year ago
parent
commit
f51bd1e1ff
No known key found for this signature in database GPG Key ID: A646B9CB645ECEA4
  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 else
{ {
if (serviceRegistrationActionList.IsClassInterceptorsDisabled) if (serviceRegistrationActionList.IsClassInterceptorsDisabled ||
serviceRegistrationActionList.DisabledClassInterceptorsSelectors.Any(selector => selector.Predicate(serviceType)))
{ {
return registrationBuilder; return registrationBuilder;
} }

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

@ -1,4 +1,5 @@
using System; using System;
using Volo.Abp;
using Volo.Abp.DependencyInjection; using Volo.Abp.DependencyInjection;
namespace Microsoft.Extensions.DependencyInjection; namespace Microsoft.Extensions.DependencyInjection;
@ -39,6 +40,11 @@ public static class ServiceCollectionRegistrationActionExtensions
return GetOrCreateRegistrationActionList(services).IsClassInterceptorsDisabled; return GetOrCreateRegistrationActionList(services).IsClassInterceptorsDisabled;
} }
public static void DisableAbpClassInterceptors(this IServiceCollection services, NamedTypeSelector selector)
{
GetOrCreateRegistrationActionList(services).DisabledClassInterceptorsSelectors.Add(selector);
}
// OnExposing // OnExposing
public static void OnExposing(this IServiceCollection services, Action<IOnServiceExposingContext> exposeAction) 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 class ServiceRegistrationActionList : List<Action<IOnServiceRegistredContext>>
{ {
public bool IsClassInterceptorsDisabled { get; set; } public bool IsClassInterceptorsDisabled { get; set; }
public IClassInterceptorsSelectorList DisabledClassInterceptorsSelectors { get; }
public ServiceRegistrationActionList()
{
DisabledClassInterceptorsSelectors = new ClassInterceptorsSelectorList();
}
} }

Loading…
Cancel
Save