From e689561936c1f8314d4c2c93778f726a6598509f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Sat, 10 Mar 2018 23:16:06 +0300 Subject: [PATCH] Created IAuthorizationEnabled and IValidationEnabled interfaces. --- .../Abp/Authorization/AbpAuthorizationModule.cs | 5 +++++ .../AuthorizationInterceptorRegistrar.cs | 15 +++++++++++++++ .../Abp/Authorization/IAuthorizationEnabled.cs | 7 +++++++ src/Volo.Abp.Ddd/Volo/Abp/AbpDddModule.cs | 6 ------ .../AuthorizationInterceptorRegistrar.cs | 17 ----------------- .../Application/Services/IApplicationService.cs | 6 ++++-- .../Services/ValidationInterceptorRegistrar.cs | 17 ----------------- .../Volo/Abp/Validation/AbpValidationModule.cs | 5 +++++ .../Volo/Abp/Validation/IValidationEnabled.cs | 7 +++++++ .../ValidationInterceptorRegistrar.cs | 16 ++++++++++++++++ 10 files changed, 59 insertions(+), 42 deletions(-) create mode 100644 src/Volo.Abp.Authorization/Volo/Abp/Authorization/AuthorizationInterceptorRegistrar.cs create mode 100644 src/Volo.Abp.Authorization/Volo/Abp/Authorization/IAuthorizationEnabled.cs delete mode 100644 src/Volo.Abp.Ddd/Volo/Abp/Application/Services/AuthorizationInterceptorRegistrar.cs delete mode 100644 src/Volo.Abp.Ddd/Volo/Abp/Application/Services/ValidationInterceptorRegistrar.cs create mode 100644 src/Volo.Abp.Validation/Volo/Abp/Validation/IValidationEnabled.cs create mode 100644 src/Volo.Abp.Validation/Volo/Abp/Validation/ValidationInterceptorRegistrar.cs diff --git a/src/Volo.Abp.Authorization/Volo/Abp/Authorization/AbpAuthorizationModule.cs b/src/Volo.Abp.Authorization/Volo/Abp/Authorization/AbpAuthorizationModule.cs index d32d110bac..3ddf6e1132 100644 --- a/src/Volo.Abp.Authorization/Volo/Abp/Authorization/AbpAuthorizationModule.cs +++ b/src/Volo.Abp.Authorization/Volo/Abp/Authorization/AbpAuthorizationModule.cs @@ -9,6 +9,11 @@ namespace Volo.Abp.Authorization [DependsOn(typeof(AbpSecurityModule))] public class AbpAuthorizationModule : AbpModule { + public override void PreConfigureServices(IServiceCollection services) + { + services.OnRegistred(AuthorizationInterceptorRegistrar.RegisterIfNeeded); + } + public override void ConfigureServices(IServiceCollection services) { services.AddAuthorization(); diff --git a/src/Volo.Abp.Authorization/Volo/Abp/Authorization/AuthorizationInterceptorRegistrar.cs b/src/Volo.Abp.Authorization/Volo/Abp/Authorization/AuthorizationInterceptorRegistrar.cs new file mode 100644 index 0000000000..76a12b6dfe --- /dev/null +++ b/src/Volo.Abp.Authorization/Volo/Abp/Authorization/AuthorizationInterceptorRegistrar.cs @@ -0,0 +1,15 @@ +using Volo.Abp.DependencyInjection; + +namespace Volo.Abp.Authorization +{ + public static class AuthorizationInterceptorRegistrar + { + public static void RegisterIfNeeded(IOnServiceRegistredContext context) + { + if (typeof(IAuthorizationEnabled).IsAssignableFrom(context.ImplementationType)) + { + context.Interceptors.TryAdd(); + } + } + } +} \ No newline at end of file diff --git a/src/Volo.Abp.Authorization/Volo/Abp/Authorization/IAuthorizationEnabled.cs b/src/Volo.Abp.Authorization/Volo/Abp/Authorization/IAuthorizationEnabled.cs new file mode 100644 index 0000000000..8563a98a8c --- /dev/null +++ b/src/Volo.Abp.Authorization/Volo/Abp/Authorization/IAuthorizationEnabled.cs @@ -0,0 +1,7 @@ +namespace Volo.Abp.Authorization +{ + public interface IAuthorizationEnabled + { + + } +} \ No newline at end of file diff --git a/src/Volo.Abp.Ddd/Volo/Abp/AbpDddModule.cs b/src/Volo.Abp.Ddd/Volo/Abp/AbpDddModule.cs index 32b70770a8..7e5ce91105 100644 --- a/src/Volo.Abp.Ddd/Volo/Abp/AbpDddModule.cs +++ b/src/Volo.Abp.Ddd/Volo/Abp/AbpDddModule.cs @@ -31,12 +31,6 @@ namespace Volo.Abp [DependsOn(typeof(AbpHttpAbstractionsModule))] public class AbpDddModule : AbpModule { - public override void PreConfigureServices(IServiceCollection services) - { - services.OnRegistred(ValidationInterceptorRegistrar.RegisterIfNeeded); - services.OnRegistred(AuthorizationInterceptorRegistrar.RegisterIfNeeded); - } - public override void ConfigureServices(IServiceCollection services) { services.Configure(options => diff --git a/src/Volo.Abp.Ddd/Volo/Abp/Application/Services/AuthorizationInterceptorRegistrar.cs b/src/Volo.Abp.Ddd/Volo/Abp/Application/Services/AuthorizationInterceptorRegistrar.cs deleted file mode 100644 index dbf7f6db42..0000000000 --- a/src/Volo.Abp.Ddd/Volo/Abp/Application/Services/AuthorizationInterceptorRegistrar.cs +++ /dev/null @@ -1,17 +0,0 @@ -using Volo.Abp.Authorization; -using Volo.Abp.DependencyInjection; - -namespace Volo.Abp.Application.Services -{ - public static class AuthorizationInterceptorRegistrar - { - public static void RegisterIfNeeded(IOnServiceRegistredContext context) - { - //TODO Create IAuthorizationEnabled interface and inherit IApplicationService from it! - if (typeof(IApplicationService).IsAssignableFrom(context.ImplementationType)) - { - context.Interceptors.TryAdd(); - } - } - } -} \ No newline at end of file diff --git a/src/Volo.Abp.Ddd/Volo/Abp/Application/Services/IApplicationService.cs b/src/Volo.Abp.Ddd/Volo/Abp/Application/Services/IApplicationService.cs index 7579d89157..8a5b0d5013 100644 --- a/src/Volo.Abp.Ddd/Volo/Abp/Application/Services/IApplicationService.cs +++ b/src/Volo.Abp.Ddd/Volo/Abp/Application/Services/IApplicationService.cs @@ -1,4 +1,6 @@ -using Volo.Abp.DependencyInjection; +using Volo.Abp.Authorization; +using Volo.Abp.Authorization.Permissions; +using Volo.Abp.DependencyInjection; using Volo.Abp.Uow; namespace Volo.Abp.Application.Services @@ -6,7 +8,7 @@ namespace Volo.Abp.Application.Services /// /// This interface must be implemented by all application services to register and identify them by convention. /// - public interface IApplicationService : ITransientDependency, IRemoteService, IUnitOfWorkEnabled + public interface IApplicationService : ITransientDependency, IRemoteService, IUnitOfWorkEnabled, IValidationEnabled, IAuthorizationEnabled { } diff --git a/src/Volo.Abp.Ddd/Volo/Abp/Application/Services/ValidationInterceptorRegistrar.cs b/src/Volo.Abp.Ddd/Volo/Abp/Application/Services/ValidationInterceptorRegistrar.cs deleted file mode 100644 index ffef57bdf7..0000000000 --- a/src/Volo.Abp.Ddd/Volo/Abp/Application/Services/ValidationInterceptorRegistrar.cs +++ /dev/null @@ -1,17 +0,0 @@ -using Volo.Abp.DependencyInjection; -using Volo.Abp.Validation; - -namespace Volo.Abp.Application.Services -{ - public static class ValidationInterceptorRegistrar - { - public static void RegisterIfNeeded(IOnServiceRegistredContext context) - { - //TODO Create IValidationEnabled interface and inherit IApplicationService from it! - if (typeof(IApplicationService).IsAssignableFrom(context.ImplementationType)) - { - context.Interceptors.TryAdd(); - } - } - } -} \ No newline at end of file diff --git a/src/Volo.Abp.Validation/Volo/Abp/Validation/AbpValidationModule.cs b/src/Volo.Abp.Validation/Volo/Abp/Validation/AbpValidationModule.cs index b49035ebb2..9bb38fbe7c 100644 --- a/src/Volo.Abp.Validation/Volo/Abp/Validation/AbpValidationModule.cs +++ b/src/Volo.Abp.Validation/Volo/Abp/Validation/AbpValidationModule.cs @@ -5,6 +5,11 @@ namespace Volo.Abp.Validation { public class AbpValidationModule : AbpModule { + public override void PreConfigureServices(IServiceCollection services) + { + services.OnRegistred(ValidationInterceptorRegistrar.RegisterIfNeeded); + } + public override void ConfigureServices(IServiceCollection services) { services.AddAssemblyOf(); diff --git a/src/Volo.Abp.Validation/Volo/Abp/Validation/IValidationEnabled.cs b/src/Volo.Abp.Validation/Volo/Abp/Validation/IValidationEnabled.cs new file mode 100644 index 0000000000..8116553fce --- /dev/null +++ b/src/Volo.Abp.Validation/Volo/Abp/Validation/IValidationEnabled.cs @@ -0,0 +1,7 @@ +namespace Volo.Abp.Application.Services +{ + public interface IValidationEnabled + { + + } +} \ No newline at end of file diff --git a/src/Volo.Abp.Validation/Volo/Abp/Validation/ValidationInterceptorRegistrar.cs b/src/Volo.Abp.Validation/Volo/Abp/Validation/ValidationInterceptorRegistrar.cs new file mode 100644 index 0000000000..75c97e0936 --- /dev/null +++ b/src/Volo.Abp.Validation/Volo/Abp/Validation/ValidationInterceptorRegistrar.cs @@ -0,0 +1,16 @@ +using Volo.Abp.Application.Services; +using Volo.Abp.DependencyInjection; + +namespace Volo.Abp.Validation +{ + public static class ValidationInterceptorRegistrar + { + public static void RegisterIfNeeded(IOnServiceRegistredContext context) + { + if (typeof(IValidationEnabled).IsAssignableFrom(context.ImplementationType)) + { + context.Interceptors.TryAdd(); + } + } + } +} \ No newline at end of file