Skip to content

Commit

Permalink
[r] namespace
Browse files Browse the repository at this point in the history
[edit] parameters
  • Loading branch information
i4004 committed May 8, 2024
1 parent 4a70b6e commit 8f47bcc
Show file tree
Hide file tree
Showing 15 changed files with 27 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Linq;
using Simplify.DI;
using Simplify.Web.Controllers.Execution;
using Simplify.Web.Controllers.Execution.Resolver;
using Simplify.Web.Controllers.Response;
using Simplify.Web.Controllers.Response.Injection;
using Simplify.Web.Controllers.V1.Execution;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using Simplify.Web.Controllers.Resolution;
using Simplify.Web.Controllers.Resolution.Stages;
using Simplify.Web.Controllers.Resolution.State;
using Simplify.Web.Controllers.RouteMatching;
using Simplify.Web.Controllers.RouteMatching.Resolver;
using Simplify.Web.Controllers.Security;

namespace Simplify.Web.Bootstrapper.Setup;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Linq;
using Simplify.DI;
using Simplify.Web.Controllers.RouteMatching;
using Simplify.Web.Controllers.RouteMatching.Resolver;
using Simplify.Web.Controllers.V1.Matcher;

namespace Simplify.Web.Bootstrapper.Setup;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Simplify.Web.Controllers.Execution.Resolver;
using Simplify.Web.Controllers.Response;

namespace Simplify.Web.Controllers.Execution;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using System.Linq;
using Simplify.Web.Controllers.Meta;

namespace Simplify.Web.Controllers.Execution;
namespace Simplify.Web.Controllers.Execution.Resolver;

public class ControllerExecutorResolver(IReadOnlyList<IControllerExecutor> executors) : IControllerExecutorResolver
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Simplify.Web.Controllers.Meta;

namespace Simplify.Web.Controllers.Execution;
namespace Simplify.Web.Controllers.Execution.Resolver;

public interface IControllerExecutorResolver
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using System.Linq;
using Microsoft.AspNetCore.Http;
using Simplify.Web.Controllers.Resolution.State;
using Simplify.Web.Controllers.RouteMatching;
using Simplify.Web.Controllers.RouteMatching.Resolver;
using Simplify.Web.Http;

namespace Simplify.Web.Controllers.Resolution.Stages;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Simplify.Web.Controllers.Meta;

namespace Simplify.Web.Controllers.RouteMatching;
namespace Simplify.Web.Controllers.RouteMatching.Resolver;

public interface IRouteMatcherResolver
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using System.Linq;
using Simplify.Web.Controllers.Meta;

namespace Simplify.Web.Controllers.RouteMatching;
namespace Simplify.Web.Controllers.RouteMatching.Resolver;

public class RouteMatcherResolver(IReadOnlyList<IRouteMatcher> matchers) : IRouteMatcherResolver
{
Expand Down
8 changes: 2 additions & 6 deletions src/Simplify.Web/PageComposition/IPageComposer.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;

namespace Simplify.Web.PageComposition;
namespace Simplify.Web.PageComposition;

/// <summary>
/// Represents a web-page composer.
Expand All @@ -11,6 +8,5 @@ public interface IPageComposer
/// <summary>
/// Composes the current web-page.
/// </summary>
/// <param name="context">The context.</param>
Task<string> ComposeAsync(HttpContext context);
string Compose();
}
5 changes: 2 additions & 3 deletions src/Simplify.Web/PageComposition/IPageCompositionStage.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Simplify.Web.Modules.Data;

namespace Simplify.Web.PageComposition;

public interface IPageCompositionStage
{
Task ExecuteAsync(HttpContext context);
void Execute(IDataCollector dataCollector);
}
7 changes: 5 additions & 2 deletions src/Simplify.Web/PageComposition/IPageGenerator.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
namespace Simplify.Web.PageComposition;
using System.Data;
using Simplify.Web.Modules.Data;

namespace Simplify.Web.PageComposition;

/// <summary>
/// Represent web-page generator.
Expand All @@ -8,5 +11,5 @@ public interface IPageGenerator
/// <summary>
/// Generates the web page HTML code.
/// </summary>
string Generate();
string Generate(IDataCollector dataCollector);
}
11 changes: 5 additions & 6 deletions src/Simplify.Web/PageComposition/PageComposer.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Simplify.Web.Modules.Data;

namespace Simplify.Web.PageComposition;

public class PageComposer(IReadOnlyList<IPageCompositionStage> stages, IPageGenerator pageGenerator) : IPageComposer
public class PageComposer(IReadOnlyList<IPageCompositionStage> stages, IDataCollector dataCollector, IPageGenerator pageGenerator) : IPageComposer
{
public async Task<string> ComposeAsync(HttpContext context)
public string Compose()
{
foreach (var item in stages)
await item.ExecuteAsync(context);
item.Execute(dataCollector);

return pageGenerator.Generate();
return pageGenerator.Generate(dataCollector);
}
}
4 changes: 2 additions & 2 deletions src/Simplify.Web/PageComposition/PageGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ namespace Simplify.Web.PageComposition;
/// <param name="templateFactory">The template factory.</param>
/// <param name="dataCollector">The data collector.</param>
/// <param name="IDynamicEnvironment">The environment.</param>
public class PageGenerator(ITemplateFactory templateFactory, IDataCollector dataCollector, IDynamicEnvironment environment) : IPageGenerator
public class PageGenerator(ITemplateFactory templateFactory, IDynamicEnvironment environment) : IPageGenerator
{
/// <summary>
/// Generates the web page HTML code
/// </summary>
public string Generate()
public string Generate(IDataCollector dataCollector)
{
var tpl = templateFactory.Load(environment.MasterTemplateFileName);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ namespace Simplify.Web.RequestHandling.Handlers;

public class PageGenerationHandler(IPageComposer pageComposer, IResponseWriter responseWriter) : IRequestHandler
{
public async Task HandleAsync(HttpContext context, RequestHandlerAsync next)
public Task HandleAsync(HttpContext context, RequestHandlerAsync next)
{
context.Response.ContentType = "text/html";

await responseWriter.WriteAsync(context.Response, await pageComposer.ComposeAsync(context));
return responseWriter.WriteAsync(context.Response, pageComposer.Compose());
}
}

0 comments on commit 8f47bcc

Please sign in to comment.