initial commit for .net 8 migration
This commit is contained in:
@@ -1,9 +1,6 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using PoweredSoft.CQRS.Abstractions;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace PoweredSoft.CQRS.AspNetCore.Mvc
|
||||
{
|
||||
|
||||
@@ -11,16 +11,16 @@ namespace PoweredSoft.CQRS.AspNetCore.Mvc
|
||||
{
|
||||
public class CommandControllerAsyncAuthorizationFilter : IAsyncAuthorizationFilter
|
||||
{
|
||||
private readonly ICommandAuthorizationService _authorizationService;
|
||||
private readonly ICommandAuthorizationService authorizationService;
|
||||
|
||||
public CommandControllerAsyncAuthorizationFilter(IServiceProvider serviceProvider)
|
||||
{
|
||||
_authorizationService = serviceProvider.GetService<ICommandAuthorizationService>();
|
||||
authorizationService = serviceProvider.GetService<ICommandAuthorizationService>();
|
||||
}
|
||||
|
||||
public async Task OnAuthorizationAsync(AuthorizationFilterContext context)
|
||||
{
|
||||
if (_authorizationService == null)
|
||||
if (authorizationService == null)
|
||||
return;
|
||||
|
||||
var action = context.ActionDescriptor as Microsoft.AspNetCore.Mvc.Controllers.ControllerActionDescriptor;
|
||||
@@ -34,7 +34,7 @@ namespace PoweredSoft.CQRS.AspNetCore.Mvc
|
||||
else
|
||||
commandType = action.ControllerTypeInfo.GenericTypeArguments.First();
|
||||
|
||||
var ar = await _authorizationService.IsAllowedAsync(commandType);
|
||||
var ar = await authorizationService.IsAllowedAsync(commandType);
|
||||
if (ar == AuthorizationResult.Forbidden)
|
||||
context.Result = new StatusCodeResult(403);
|
||||
else if(ar == AuthorizationResult.Unauthorized)
|
||||
|
||||
@@ -16,13 +16,19 @@ namespace PoweredSoft.CQRS.AspNetCore.Mvc
|
||||
|
||||
public void Apply(ControllerModel controller)
|
||||
{
|
||||
if (controller.ControllerType.IsGenericType && controller.ControllerType.Name.Contains("CommandController") && controller.ControllerType.Assembly == typeof(CommandControllerConvention).Assembly)
|
||||
{
|
||||
var genericType = controller.ControllerType.GenericTypeArguments[0];
|
||||
var commandDiscovery = this.serviceProvider.GetRequiredService<ICommandDiscovery>();
|
||||
var command = commandDiscovery.FindCommand(genericType);
|
||||
controller.ControllerName = command.LowerCamelCaseName;
|
||||
}
|
||||
if (!controller.ControllerType.IsGenericType)
|
||||
return;
|
||||
|
||||
if (!controller.ControllerType.Name.Contains("CommandController"))
|
||||
return;
|
||||
|
||||
if (controller.ControllerType.Assembly != typeof(CommandControllerConvention).Assembly)
|
||||
return;
|
||||
|
||||
var genericType = controller.ControllerType.GenericTypeArguments[0];
|
||||
var commandDiscovery = this.serviceProvider.GetRequiredService<ICommandDiscovery>();
|
||||
var command = commandDiscovery.FindCommand(genericType);
|
||||
controller.ControllerName = command.LowerCamelCaseName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
using Microsoft.AspNetCore.Mvc.ApplicationParts;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using Microsoft.AspNetCore.Mvc.ApplicationParts;
|
||||
using Microsoft.AspNetCore.Mvc.Controllers;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using PoweredSoft.CQRS.Abstractions.Discovery;
|
||||
using PoweredSoft.CQRS.AspNetCore.Abstractions.Attributes;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
|
||||
namespace PoweredSoft.CQRS.AspNetCore.Mvc
|
||||
{
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using PoweredSoft.CQRS.Abstractions;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace PoweredSoft.CQRS.AspNetCore.Mvc
|
||||
{
|
||||
|
||||
@@ -11,16 +11,16 @@ namespace PoweredSoft.CQRS.AspNetCore.Mvc
|
||||
{
|
||||
public class QueryControllerAsyncAuthorizationFilter : IAsyncAuthorizationFilter
|
||||
{
|
||||
private readonly IQueryAuthorizationService _authorizationService;
|
||||
private readonly IQueryAuthorizationService authorizationService;
|
||||
|
||||
public QueryControllerAsyncAuthorizationFilter(IServiceProvider serviceProvider)
|
||||
{
|
||||
_authorizationService = serviceProvider.GetService<IQueryAuthorizationService>();
|
||||
authorizationService = serviceProvider.GetService<IQueryAuthorizationService>();
|
||||
}
|
||||
|
||||
public async Task OnAuthorizationAsync(AuthorizationFilterContext context)
|
||||
{
|
||||
if (_authorizationService == null)
|
||||
if (authorizationService == null)
|
||||
return;
|
||||
|
||||
var action = context.ActionDescriptor as Microsoft.AspNetCore.Mvc.Controllers.ControllerActionDescriptor;
|
||||
@@ -34,7 +34,7 @@ namespace PoweredSoft.CQRS.AspNetCore.Mvc
|
||||
else
|
||||
queryType = action.ControllerTypeInfo.GenericTypeArguments.First();
|
||||
|
||||
var ar = await _authorizationService.IsAllowedAsync(queryType);
|
||||
var ar = await authorizationService.IsAllowedAsync(queryType);
|
||||
if (ar == AuthorizationResult.Forbidden)
|
||||
context.Result = new StatusCodeResult(403);
|
||||
else if (ar == AuthorizationResult.Unauthorized)
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
using Microsoft.AspNetCore.Mvc.ApplicationParts;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using Microsoft.AspNetCore.Mvc.ApplicationParts;
|
||||
using Microsoft.AspNetCore.Mvc.Controllers;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using PoweredSoft.CQRS.Abstractions.Discovery;
|
||||
using PoweredSoft.CQRS.AspNetCore.Abstractions.Attributes;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
|
||||
namespace PoweredSoft.CQRS.AspNetCore.Mvc
|
||||
{
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace PoweredSoft.CQRS.AspNetCore.Mvc
|
||||
namespace PoweredSoft.CQRS.AspNetCore.Mvc
|
||||
{
|
||||
public class QueryControllerOptions
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user