• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

Revisiónb427e425b57b6484ff1ae9a445582d1eb8c6172c (tree)
Tiempo2022-06-04 21:24:52
Autoryoshy <yoshy.org.bitbucket@gz.j...>
Commiteryoshy

Log Message

[ADD] WindowController の抽象実装および単純実装をフレームワーク側に追加

Cambiar Resumen

Diferencia incremental

--- /dev/null
+++ b/Adaptor/Controller/AbstractAsyncWindowController.cs
@@ -0,0 +1,39 @@
1+using CleanAuLait48.Adaptor.Boundary.Controller;
2+using CleanAuLait48.Core.DI;
3+using CleanAuLait48.UseCase.Request;
4+using CleanAuLait48.UseCase.Response;
5+using System.Threading.Tasks;
6+
7+namespace CleanAuLait48.Adaptor.Controller
8+{
9+ public abstract class AbstractAsyncWindowController : IAsyncWindowController
10+ {
11+ public static readonly string DEFAULT_HANDLER_QUEUE = "defaultHandlerQueue";
12+
13+ private readonly IRequestScopeGenerator scopedGenerator;
14+ private readonly IAsyncHandlerContextFactory contextFactory;
15+
16+ public AbstractAsyncWindowController(
17+ IRequestScopeGenerator scopedGenerator,
18+ IAsyncHandlerContextFactory contextFactory)
19+ {
20+ this.scopedGenerator = scopedGenerator;
21+ this.contextFactory = contextFactory;
22+ }
23+
24+ public virtual async Task<UseCaseResponse> ExecuteAsync(UseCaseRequest req)
25+ {
26+ return await ExecuteAsync(DEFAULT_HANDLER_QUEUE, req);
27+ }
28+
29+ protected async Task<UseCaseResponse> ExecuteAsync(string handlerQueueName, UseCaseRequest req)
30+ {
31+ using (IScopedComponentProvider scope = scopedGenerator.CreateScope())
32+ {
33+ IAsyncHandlerContext context = contextFactory.Create(handlerQueueName, scope);
34+
35+ return await context.HandleNextAsync(req, context);
36+ }
37+ }
38+ }
39+}
--- /dev/null
+++ b/Adaptor/Controller/AbstractWindowController.cs
@@ -0,0 +1,43 @@
1+using CleanAuLait48.Adaptor.Boundary.Controller;
2+using CleanAuLait48.Core.DI;
3+using CleanAuLait48.UseCase.Request;
4+using CleanAuLait48.UseCase.Response;
5+
6+namespace CleanAuLait48.Adaptor.Controller
7+{
8+ public abstract class AbstractWindowController : IWindowController
9+ {
10+ public static readonly string DEFAULT_HANDLER_QUEUE = "defaultHandlerQueue";
11+
12+ protected readonly IRequestScopeGenerator scopedGenerator;
13+ protected readonly IHandlerContextFactory contextFactory;
14+
15+ protected readonly object lockExecute = new object();
16+
17+ public AbstractWindowController(
18+ IRequestScopeGenerator scopedGenerator,
19+ IHandlerContextFactory contextFactory)
20+ {
21+ this.scopedGenerator = scopedGenerator;
22+ this.contextFactory = contextFactory;
23+ }
24+
25+ public virtual UseCaseResponse Execute(UseCaseRequest req)
26+ {
27+ return Execute(DEFAULT_HANDLER_QUEUE, req);
28+ }
29+
30+ protected UseCaseResponse Execute(string handlerQueueName, UseCaseRequest req)
31+ {
32+ lock (lockExecute)
33+ {
34+ using (IScopedComponentProvider scope = this.scopedGenerator.CreateScope())
35+ {
36+ IHandlerContext context = this.contextFactory.Create(handlerQueueName, scope);
37+
38+ return context.HandleNext(req, context);
39+ }
40+ }
41+ }
42+ }
43+}
--- /dev/null
+++ b/Adaptor/Controller/AsyncSimpleWindowController.cs
@@ -0,0 +1,15 @@
1+using CleanAuLait48.Adaptor.Boundary.Controller;
2+using CleanAuLait48.Core.DI;
3+
4+namespace CleanAuLait48.Adaptor.Controller
5+{
6+ internal class AsyncSimpleWindowController : AbstractAsyncWindowController
7+ {
8+ public AsyncSimpleWindowController(
9+ IRequestScopeGenerator scopedGenerator,
10+ IAsyncHandlerContextFactory contextFactory) :
11+ base(scopedGenerator, contextFactory)
12+ {
13+ }
14+ }
15+}
--- /dev/null
+++ b/Adaptor/Controller/SimpleWindowController.cs
@@ -0,0 +1,15 @@
1+using CleanAuLait48.Adaptor.Boundary.Controller;
2+using CleanAuLait48.Core.DI;
3+
4+namespace CleanAuLait48.Adaptor.Controller
5+{
6+ public class SimpleWindowController : AbstractWindowController
7+ {
8+ public SimpleWindowController(
9+ IRequestScopeGenerator scopedGenerator,
10+ IHandlerContextFactory contextFactory) :
11+ base(scopedGenerator, contextFactory)
12+ {
13+ }
14+ }
15+}
--- a/CleanAuLait48.csproj
+++ b/CleanAuLait48.csproj
@@ -55,9 +55,13 @@
5555 </ItemGroup>
5656 <ItemGroup>
5757 <Compile Include="Adaptor\Boundary\Controller\IAttachHandlerQueueMap.cs" />
58+ <Compile Include="Adaptor\Controller\AbstractAsyncWindowController.cs" />
5859 <Compile Include="Adaptor\Controller\AbstractHandlerContextFactoryRegistrar.cs" />
60+ <Compile Include="Adaptor\Controller\AbstractWindowController.cs" />
5961 <Compile Include="Adaptor\Controller\AsyncHandlerContextFactoryRegistrar.cs" />
62+ <Compile Include="Adaptor\Controller\AsyncSimpleWindowController.cs" />
6063 <Compile Include="Adaptor\Controller\HandlerContextFactoryRegistrar.cs" />
64+ <Compile Include="Adaptor\Controller\SimpleWindowController.cs" />
6165 <Compile Include="CleanAuLait48ComponentRegisterer.cs" />
6266 <Compile Include="Adaptor\Boundary\Controller\Handler\IAsyncRequestHandler.cs" />
6367 <Compile Include="Adaptor\Boundary\Controller\Handler\IRequestHandler.cs" />