Created IAuthorizationEnabled and IValidationEnabled interfaces.

pull/272/head
Halil İbrahim Kalkan 7 years ago
parent d66d4c46b2
commit e689561936

@ -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();

@ -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<AuthorizationInterceptor>();
}
}
}
}

@ -0,0 +1,7 @@
namespace Volo.Abp.Authorization
{
public interface IAuthorizationEnabled
{
}
}

@ -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<ApiDescriptionModelOptions>(options =>

@ -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<AuthorizationInterceptor>();
}
}
}
}

@ -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
/// <summary>
/// This interface must be implemented by all application services to register and identify them by convention.
/// </summary>
public interface IApplicationService : ITransientDependency, IRemoteService, IUnitOfWorkEnabled
public interface IApplicationService : ITransientDependency, IRemoteService, IUnitOfWorkEnabled, IValidationEnabled, IAuthorizationEnabled
{
}

@ -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<ValidationInterceptor>();
}
}
}
}

@ -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<AbpValidationModule>();

@ -0,0 +1,7 @@
namespace Volo.Abp.Application.Services
{
public interface IValidationEnabled
{
}
}

@ -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<ValidationInterceptor>();
}
}
}
}
Loading…
Cancel
Save