Skip to content

Commit 218babc

Browse files
committed
[add] controllers execution process
[del] redundant types
1 parent 4be5d4b commit 218babc

16 files changed

Lines changed: 41 additions & 201 deletions

src/Simplify.Web/Controllers/Execution/Args/ControllerExecutionArgs.cs

Lines changed: 0 additions & 16 deletions
This file was deleted.

src/Simplify.Web/Controllers/Execution/Args/IControllerExecutionArgs.cs

Lines changed: 0 additions & 26 deletions
This file was deleted.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using System.Collections.Generic;
2+
using System.Threading.Tasks;
3+
using Microsoft.AspNetCore.Http;
4+
using Simplify.Web.Controllers.Response;
5+
6+
namespace Simplify.Web.Controllers.Execution;
7+
8+
public class ControllersExecutor(IControllerExecutorResolver executorResolver, IControllerResponseExecutor responseExecutor) : IControllersExecutor
9+
{
10+
public async Task<ResponseBehavior> ExecuteAsync(IReadOnlyList<IMatchedController> controllers, HttpContext context)
11+
{
12+
foreach (var controller in controllers)
13+
{
14+
var response = await executorResolver.Resolve(controller.Controller).ExecuteAsync(controller, context);
15+
16+
if (response == null)
17+
continue;
18+
19+
var result = await responseExecutor.ExecuteAsync(response);
20+
21+
if (result != ResponseBehavior.Default)
22+
return result;
23+
}
24+
25+
return ResponseBehavior.Default;
26+
}
27+
}

src/Simplify.Web/Controllers/Execution/Extensions/ControllerMetaDataExtensions.cs

Lines changed: 0 additions & 11 deletions
This file was deleted.

src/Simplify.Web/Controllers/Execution/Extensions/ControllerProcessingContextExtensions.cs

Lines changed: 0 additions & 10 deletions
This file was deleted.

src/Simplify.Web/Controllers/Execution/IControllerExecutor.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
using System.Threading.Tasks;
2-
using Simplify.Web.Controllers.Execution.Args;
2+
using Microsoft.AspNetCore.Http;
33
using Simplify.Web.Meta.Controllers;
44

55
namespace Simplify.Web.Controllers.Execution;
@@ -15,8 +15,9 @@ public interface IControllerExecutor
1515
bool CanHandle(IControllerMetadata args);
1616

1717
/// <summary>
18-
/// Creates and executes the controller.
18+
/// Creates the actual controller and executes it.
1919
/// </summary>
20-
/// <param name="args">The controller execution args.</param>
21-
Task<ControllerResponse?> Execute(IControllerExecutionArgs args);
20+
/// <param name="args">The matched controller.</param>
21+
/// <param name="context">The HTTP contexts.</param>
22+
Task<ControllerResponse?> ExecuteAsync(IMatchedController controller, HttpContext context);
2223
}

src/Simplify.Web/Controllers/Execution/IControllersExecutor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ namespace Simplify.Web.Controllers.Execution;
66

77
public interface IControllersExecutor
88
{
9-
public Task<ResponseBehavior> ExecuteAsync(IReadOnlyList<IMatchedController> Controllers, HttpContext context);
9+
public Task<ResponseBehavior> ExecuteAsync(IReadOnlyList<IMatchedController> controllers, HttpContext context);
1010
}

src/Simplify.Web/Controllers/Processing/BaseControllerProcessor.cs

Lines changed: 0 additions & 40 deletions
This file was deleted.

src/Simplify.Web/Controllers/Processing/Context/ControllerProcessingContext.cs

Lines changed: 0 additions & 14 deletions
This file was deleted.

src/Simplify.Web/Controllers/Processing/Context/IControllerProcessingContext.cs

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)