Revisão | b427e425b57b6484ff1ae9a445582d1eb8c6172c (tree) |
---|---|
Hora | 2022-06-04 21:24:52 |
Autor | yoshy <yoshy.org.bitbucket@gz.j...> |
Commiter | yoshy |
[ADD] WindowController の抽象実装および単純実装をフレームワーク側に追加
@@ -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 | +} |
@@ -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 | +} |
@@ -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 | +} |
@@ -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 | +} |
@@ -55,9 +55,13 @@ | ||
55 | 55 | </ItemGroup> |
56 | 56 | <ItemGroup> |
57 | 57 | <Compile Include="Adaptor\Boundary\Controller\IAttachHandlerQueueMap.cs" /> |
58 | + <Compile Include="Adaptor\Controller\AbstractAsyncWindowController.cs" /> | |
58 | 59 | <Compile Include="Adaptor\Controller\AbstractHandlerContextFactoryRegistrar.cs" /> |
60 | + <Compile Include="Adaptor\Controller\AbstractWindowController.cs" /> | |
59 | 61 | <Compile Include="Adaptor\Controller\AsyncHandlerContextFactoryRegistrar.cs" /> |
62 | + <Compile Include="Adaptor\Controller\AsyncSimpleWindowController.cs" /> | |
60 | 63 | <Compile Include="Adaptor\Controller\HandlerContextFactoryRegistrar.cs" /> |
64 | + <Compile Include="Adaptor\Controller\SimpleWindowController.cs" /> | |
61 | 65 | <Compile Include="CleanAuLait48ComponentRegisterer.cs" /> |
62 | 66 | <Compile Include="Adaptor\Boundary\Controller\Handler\IAsyncRequestHandler.cs" /> |
63 | 67 | <Compile Include="Adaptor\Boundary\Controller\Handler\IRequestHandler.cs" /> |