Browse Source
Add support for selective disabling of class interceptors
pull/23380/head
maliming
1 year ago
No known key found for this signature in database
GPG Key ID: A646B9CB645ECEA4
5 changed files with
31 additions and
1 deletions
-
framework/src/Volo.Abp.Autofac/Autofac/Builder/AbpRegistrationBuilderExtensions.cs
-
framework/src/Volo.Abp.Core/Microsoft/Extensions/DependencyInjection/ServiceCollectionRegistrationActionExtensions.cs
-
framework/src/Volo.Abp.Core/Volo/Abp/DependencyInjection/ClassInterceptorsSelectorList.cs
-
framework/src/Volo.Abp.Core/Volo/Abp/DependencyInjection/IClassInterceptorsSelectorList.cs
-
framework/src/Volo.Abp.Core/Volo/Abp/DependencyInjection/ServiceRegistrationActionList.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; |
|
|
} |
|
|
} |
|
|
|
|
|
@ -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) |
|
|
|
|
|
@ -0,0 +1,8 @@ |
|
|
|
|
|
using System.Collections.Generic; |
|
|
|
|
|
|
|
|
|
|
|
namespace Volo.Abp.DependencyInjection; |
|
|
|
|
|
|
|
|
|
|
|
public class ClassInterceptorsSelectorList : List<NamedTypeSelector>, IClassInterceptorsSelectorList |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
@ -0,0 +1,8 @@ |
|
|
|
|
|
using System.Collections.Generic; |
|
|
|
|
|
|
|
|
|
|
|
namespace Volo.Abp.DependencyInjection; |
|
|
|
|
|
|
|
|
|
|
|
public interface IClassInterceptorsSelectorList : IList<NamedTypeSelector> |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
@ -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(); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|