Révision | 1b284cdef6f5db2ffd340fc0963c2fa76eb6b9d2 (tree) |
---|---|
l'heure | 2022-08-12 00:19:55 |
Auteur | yoshy <yoshy.org.bitbucket@gz.j...> |
Commiter | yoshy |
[MOD] CleanAuLait から Prism 関連の実装を分離
@@ -1,7 +1,7 @@ | ||
1 | 1 | using CleanAuLait.Adaptor.Boundary.Controller.Handler; |
2 | +using CleanAuLait.Adaptor.Controller.DI; | |
2 | 3 | using CleanAuLait.UseCase.Request; |
3 | 4 | using CleanAuLait.UseCase.Response; |
4 | -using Prism.Ioc; | |
5 | 5 | |
6 | 6 | namespace CleanAuLait.Adaptor.Boundary.Controller |
7 | 7 | { |
@@ -9,7 +9,7 @@ namespace CleanAuLait.Adaptor.Boundary.Controller | ||
9 | 9 | { |
10 | 10 | Queue<IAsyncRequestHandler> HandlerQueue { get; } |
11 | 11 | |
12 | - IScopedProvider ScopedProvider { get; } | |
12 | + IRequestScopedProvider ScopedProvider { get; } | |
13 | 13 | |
14 | 14 | Task<UseCaseResponse> HandleNextAsync(UseCaseRequest req, IAsyncHandlerContext context); |
15 | 15 | } |
@@ -1,10 +1,10 @@ | ||
1 | -using Prism.Ioc; | |
1 | +using CleanAuLait.Adaptor.Controller.DI; | |
2 | 2 | |
3 | 3 | namespace CleanAuLait.Adaptor.Boundary.Controller |
4 | 4 | { |
5 | 5 | public interface IAsyncHandlerContextFactory : IAttachHandlerQueueMap |
6 | 6 | { |
7 | 7 | IAsyncHandlerContext Create( |
8 | - string handlerTypesName,IScopedProvider scopedProvider); | |
8 | + string handlerTypesName, IRequestScopedProvider scopedProvider); | |
9 | 9 | } |
10 | 10 | } |
\ No newline at end of file |
@@ -1,7 +1,7 @@ | ||
1 | 1 | using CleanAuLait.Adaptor.Boundary.Controller.Handler; |
2 | +using CleanAuLait.Adaptor.Controller.DI; | |
2 | 3 | using CleanAuLait.UseCase.Request; |
3 | 4 | using CleanAuLait.UseCase.Response; |
4 | -using Prism.Ioc; | |
5 | 5 | |
6 | 6 | namespace CleanAuLait.Adaptor.Boundary.Controller |
7 | 7 | { |
@@ -9,7 +9,7 @@ namespace CleanAuLait.Adaptor.Boundary.Controller | ||
9 | 9 | { |
10 | 10 | Queue<IRequestHandler> HandlerQueue { get; } |
11 | 11 | |
12 | - IScopedProvider ScopedProvider { get; } | |
12 | + IRequestScopedProvider ScopedProvider { get; } | |
13 | 13 | |
14 | 14 | UseCaseResponse HandleNext(UseCaseRequest req, IHandlerContext context); |
15 | 15 | } |
@@ -1,10 +1,10 @@ | ||
1 | -using Prism.Ioc; | |
1 | +using CleanAuLait.Adaptor.Controller.DI; | |
2 | 2 | |
3 | 3 | namespace CleanAuLait.Adaptor.Boundary.Controller |
4 | 4 | { |
5 | 5 | public interface IHandlerContextFactory : IAttachHandlerQueueMap |
6 | 6 | { |
7 | 7 | IHandlerContext Create( |
8 | - string handlerTypesName, IScopedProvider scopedProvider); | |
8 | + string handlerTypesName, IRequestScopedProvider scopedProvider); | |
9 | 9 | } |
10 | 10 | } |
\ No newline at end of file |
@@ -1,8 +1,7 @@ | ||
1 | 1 | using CleanAuLait.Adaptor.Boundary.Controller; |
2 | -using CleanAuLait.Core.DI; | |
2 | +using CleanAuLait.Adaptor.Controller.DI; | |
3 | 3 | using CleanAuLait.UseCase.Request; |
4 | 4 | using CleanAuLait.UseCase.Response; |
5 | -using Prism.Ioc; | |
6 | 5 | |
7 | 6 | namespace CleanAuLait.Adaptor.Controller |
8 | 7 | { |
@@ -28,7 +27,7 @@ namespace CleanAuLait.Adaptor.Controller | ||
28 | 27 | |
29 | 28 | protected async Task<UseCaseResponse> ExecuteAsync(string handlerQueueName, UseCaseRequest req) |
30 | 29 | { |
31 | - using IScopedProvider scope = scopedGenerator.CreateScope(); | |
30 | + using IRequestScopedProvider scope = scopedGenerator.CreateScope(); | |
32 | 31 | IAsyncHandlerContext context = contextFactory.Create(handlerQueueName, scope); |
33 | 32 | |
34 | 33 | return await context.HandleNextAsync(req, context); |
@@ -1,5 +1,4 @@ | ||
1 | 1 | using CleanAuLait.Adaptor.Boundary.Controller; |
2 | -using Prism.Ioc; | |
3 | 2 | |
4 | 3 | namespace CleanAuLait.Adaptor.Controller |
5 | 4 | { |
@@ -14,9 +13,11 @@ namespace CleanAuLait.Adaptor.Controller | ||
14 | 13 | map.Add(factoryName, handlerTypes); |
15 | 14 | } |
16 | 15 | |
17 | - public void Register(IContainerRegistry registry) | |
16 | + public abstract void Register(); | |
17 | + | |
18 | + protected Func<IFACTORY> CreateFactoryFactory() | |
18 | 19 | { |
19 | - registry.RegisterSingleton<IFACTORY>(() => | |
20 | + return () => | |
20 | 21 | { |
21 | 22 | IFACTORY factory = new FACTORY |
22 | 23 | { |
@@ -24,7 +25,7 @@ namespace CleanAuLait.Adaptor.Controller | ||
24 | 25 | }; |
25 | 26 | |
26 | 27 | return factory; |
27 | - }); | |
28 | + }; | |
28 | 29 | } |
29 | 30 | } |
30 | 31 | } |
@@ -1,8 +1,7 @@ | ||
1 | 1 | using CleanAuLait.Adaptor.Boundary.Controller; |
2 | -using CleanAuLait.Core.DI; | |
2 | +using CleanAuLait.Adaptor.Controller.DI; | |
3 | 3 | using CleanAuLait.UseCase.Request; |
4 | 4 | using CleanAuLait.UseCase.Response; |
5 | -using Prism.Ioc; | |
6 | 5 | |
7 | 6 | namespace CleanAuLait.Adaptor.Controller |
8 | 7 | { |
@@ -32,7 +31,7 @@ namespace CleanAuLait.Adaptor.Controller | ||
32 | 31 | { |
33 | 32 | lock (lockExecute) |
34 | 33 | { |
35 | - using IScopedProvider scope = this.scopedGenerator.CreateScope(); | |
34 | + using IRequestScopedProvider scope = this.scopedGenerator.CreateScope(); | |
36 | 35 | IHandlerContext context = this.contextFactory.Create(handlerQueueName, scope); |
37 | 36 | |
38 | 37 | return context.HandleNext(req, context); |
@@ -1,8 +1,8 @@ | ||
1 | 1 | using CleanAuLait.Adaptor.Boundary.Controller; |
2 | 2 | using CleanAuLait.Adaptor.Boundary.Controller.Handler; |
3 | +using CleanAuLait.Adaptor.Controller.DI; | |
3 | 4 | using CleanAuLait.Adaptor.Controller.Handler; |
4 | 5 | using CleanAuLait.Core.DI; |
5 | -using Prism.Ioc; | |
6 | 6 | |
7 | 7 | namespace CleanAuLait.Adaptor.Controller |
8 | 8 | { |
@@ -10,7 +10,7 @@ namespace CleanAuLait.Adaptor.Controller | ||
10 | 10 | { |
11 | 11 | public IDictionary<string, IEnumerable<Type>> HandlerQueueMap { get; set; } |
12 | 12 | |
13 | - public IAsyncHandlerContext Create(string handlerQueueName, IScopedProvider scopedProvider) | |
13 | + public IAsyncHandlerContext Create(string handlerQueueName, IRequestScopedProvider scopedProvider) | |
14 | 14 | { |
15 | 15 | if (!HandlerQueueMap.TryGetValue(handlerQueueName, out IEnumerable<Type> handlerTypes)) |
16 | 16 | { |
@@ -21,7 +21,7 @@ namespace CleanAuLait.Adaptor.Controller | ||
21 | 21 | } |
22 | 22 | |
23 | 23 | protected static IAsyncHandlerContext CreateInternal( |
24 | - IScopedProvider scopedProvider, IEnumerable<Type> handlerTypes) | |
24 | + IRequestScopedProvider scopedProvider, IEnumerable<Type> handlerTypes) | |
25 | 25 | { |
26 | 26 | Queue<IAsyncRequestHandler> queue = CreateHandlerQueue(scopedProvider, handlerTypes); |
27 | 27 |
@@ -31,7 +31,7 @@ namespace CleanAuLait.Adaptor.Controller | ||
31 | 31 | } |
32 | 32 | |
33 | 33 | protected static Queue<IAsyncRequestHandler> CreateHandlerQueue( |
34 | - IScopedProvider scopedProvider, IEnumerable<Type> handlerTypes) | |
34 | + IRequestScopedProvider scopedProvider, IEnumerable<Type> handlerTypes) | |
35 | 35 | { |
36 | 36 | Queue<IAsyncRequestHandler> queue = new(); |
37 | 37 |
@@ -1,9 +0,0 @@ | ||
1 | -using CleanAuLait.Adaptor.Boundary.Controller; | |
2 | - | |
3 | -namespace CleanAuLait.Adaptor.Controller | |
4 | -{ | |
5 | - public class AsyncHandlerContextFactoryRegistrar : | |
6 | - AbstractHandlerContextFactoryRegistrar<IAsyncHandlerContextFactory, AsyncHandlerContextFactory> | |
7 | - { | |
8 | - } | |
9 | -} |
@@ -1,5 +1,5 @@ | ||
1 | 1 | using CleanAuLait.Adaptor.Boundary.Controller; |
2 | -using CleanAuLait.Core.DI; | |
2 | +using CleanAuLait.Adaptor.Controller.DI; | |
3 | 3 | |
4 | 4 | namespace CleanAuLait.Adaptor.Controller |
5 | 5 | { |
@@ -0,0 +1,7 @@ | ||
1 | +namespace CleanAuLait.Adaptor.Controller.DI | |
2 | +{ | |
3 | + public interface IRequestScopeGenerator | |
4 | + { | |
5 | + IRequestScopedProvider CreateScope(); | |
6 | + } | |
7 | +} | |
\ No newline at end of file |
@@ -0,0 +1,7 @@ | ||
1 | +namespace CleanAuLait.Adaptor.Controller.DI | |
2 | +{ | |
3 | + public interface IRequestScopedProvider : IDisposable | |
4 | + { | |
5 | + object Resolve(Type type); | |
6 | + } | |
7 | +} |
@@ -1,17 +1,17 @@ | ||
1 | 1 | using CleanAuLait.Adaptor.Boundary.Controller; |
2 | 2 | using CleanAuLait.Adaptor.Boundary.Controller.Handler; |
3 | +using CleanAuLait.Adaptor.Controller.DI; | |
3 | 4 | using CleanAuLait.UseCase.Request; |
4 | 5 | using CleanAuLait.UseCase.Response; |
5 | -using Prism.Ioc; | |
6 | 6 | |
7 | 7 | namespace CleanAuLait.Adaptor.Controller.Handler |
8 | 8 | { |
9 | 9 | public class AsyncHandlerContext : IAsyncHandlerContext |
10 | 10 | { |
11 | 11 | public Queue<IAsyncRequestHandler> HandlerQueue { get; } |
12 | - public IScopedProvider ScopedProvider { get; } | |
12 | + public IRequestScopedProvider ScopedProvider { get; } | |
13 | 13 | |
14 | - public AsyncHandlerContext(Queue<IAsyncRequestHandler> queue, IScopedProvider scopedProvider) | |
14 | + public AsyncHandlerContext(Queue<IAsyncRequestHandler> queue, IRequestScopedProvider scopedProvider) | |
15 | 15 | { |
16 | 16 | this.HandlerQueue = queue; |
17 | 17 | this.ScopedProvider = scopedProvider; |
@@ -1,17 +1,17 @@ | ||
1 | 1 | using CleanAuLait.Adaptor.Boundary.Controller; |
2 | 2 | using CleanAuLait.Adaptor.Boundary.Controller.Handler; |
3 | +using CleanAuLait.Adaptor.Controller.DI; | |
3 | 4 | using CleanAuLait.UseCase.Request; |
4 | 5 | using CleanAuLait.UseCase.Response; |
5 | -using Prism.Ioc; | |
6 | 6 | |
7 | 7 | namespace CleanAuLait.Adaptor.Controller.Handler |
8 | 8 | { |
9 | 9 | public class HandlerContext : IHandlerContext |
10 | 10 | { |
11 | 11 | public Queue<IRequestHandler> HandlerQueue { get; } |
12 | - public IScopedProvider ScopedProvider { get; } | |
12 | + public IRequestScopedProvider ScopedProvider { get; } | |
13 | 13 | |
14 | - public HandlerContext(Queue<IRequestHandler> queue, IScopedProvider scopedProvider) | |
14 | + public HandlerContext(Queue<IRequestHandler> queue, IRequestScopedProvider scopedProvider) | |
15 | 15 | { |
16 | 16 | this.HandlerQueue = queue; |
17 | 17 | this.ScopedProvider = scopedProvider; |
@@ -1,8 +1,8 @@ | ||
1 | 1 | using CleanAuLait.Adaptor.Boundary.Controller; |
2 | 2 | using CleanAuLait.Adaptor.Boundary.Controller.Handler; |
3 | +using CleanAuLait.Adaptor.Controller.DI; | |
3 | 4 | using CleanAuLait.Adaptor.Controller.Handler; |
4 | 5 | using CleanAuLait.Core.DI; |
5 | -using Prism.Ioc; | |
6 | 6 | |
7 | 7 | namespace CleanAuLait.Adaptor.Controller |
8 | 8 | { |
@@ -10,7 +10,7 @@ namespace CleanAuLait.Adaptor.Controller | ||
10 | 10 | { |
11 | 11 | public IDictionary<string, IEnumerable<Type>> HandlerQueueMap { get; set; } |
12 | 12 | |
13 | - public IHandlerContext Create(string handlerQueueName, IScopedProvider scopedProvider) | |
13 | + public IHandlerContext Create(string handlerQueueName, IRequestScopedProvider scopedProvider) | |
14 | 14 | { |
15 | 15 | if (!HandlerQueueMap.TryGetValue(handlerQueueName, out IEnumerable<Type> handlerTypes)) |
16 | 16 | { |
@@ -21,7 +21,7 @@ namespace CleanAuLait.Adaptor.Controller | ||
21 | 21 | } |
22 | 22 | |
23 | 23 | protected static IHandlerContext CreateInternal( |
24 | - IScopedProvider scopedProvider, IEnumerable<Type> handlerTypes) | |
24 | + IRequestScopedProvider scopedProvider, IEnumerable<Type> handlerTypes) | |
25 | 25 | { |
26 | 26 | Queue<IRequestHandler> queue = CreateHandlerQueue(scopedProvider, handlerTypes); |
27 | 27 |
@@ -31,7 +31,7 @@ namespace CleanAuLait.Adaptor.Controller | ||
31 | 31 | } |
32 | 32 | |
33 | 33 | protected static Queue<IRequestHandler> CreateHandlerQueue( |
34 | - IScopedProvider scopedProvider, IEnumerable<Type> handlerTypes) | |
34 | + IRequestScopedProvider scopedProvider, IEnumerable<Type> handlerTypes) | |
35 | 35 | { |
36 | 36 | Queue<IRequestHandler> queue = new(); |
37 | 37 |
@@ -1,9 +0,0 @@ | ||
1 | -using CleanAuLait.Adaptor.Boundary.Controller; | |
2 | - | |
3 | -namespace CleanAuLait.Adaptor.Controller | |
4 | -{ | |
5 | - public class HandlerContextFactoryRegistrar : | |
6 | - AbstractHandlerContextFactoryRegistrar<IHandlerContextFactory, HandlerContextFactory> | |
7 | - { | |
8 | - } | |
9 | -} |
@@ -1,7 +1,7 @@ | ||
1 | -using CleanAuLait.Core.DI; | |
1 | +using CleanAuLait.Adaptor.Controller.DI; | |
2 | +using CleanAuLait.Core.DI; | |
2 | 3 | using CleanAuLait.UseCase.Boundary.Interactor; |
3 | 4 | using NLog; |
4 | -using Prism.Ioc; | |
5 | 5 | |
6 | 6 | namespace CleanAuLait.Adaptor.Controller.Router |
7 | 7 | { |
@@ -9,7 +9,7 @@ namespace CleanAuLait.Adaptor.Controller.Router | ||
9 | 9 | { |
10 | 10 | private static readonly ILogger logger = LogManager.GetCurrentClassLogger(); |
11 | 11 | |
12 | - protected T GetComponent(IScopedProvider scopedProvider, IUseCaseRouterAware req) | |
12 | + protected T GetComponent(IRequestScopedProvider scopedProvider, IUseCaseRouterAware req) | |
13 | 13 | { |
14 | 14 | Type interactorType = req.GetInteractorType(); |
15 | 15 |
@@ -19,14 +19,7 @@ namespace CleanAuLait.Adaptor.Controller.Router | ||
19 | 19 | return default; |
20 | 20 | } |
21 | 21 | |
22 | - try | |
23 | - { | |
24 | - return (T)scopedProvider.Resolve(interactorType); | |
25 | - } | |
26 | - catch (ContainerResolutionException e) | |
27 | - { | |
28 | - throw new DIException(e); | |
29 | - } | |
22 | + return (T)scopedProvider.Resolve(interactorType); | |
30 | 23 | } |
31 | 24 | } |
32 | 25 | } |
\ No newline at end of file |
@@ -1,5 +1,5 @@ | ||
1 | 1 | using CleanAuLait.Adaptor.Boundary.Controller; |
2 | -using CleanAuLait.Core.DI; | |
2 | +using CleanAuLait.Adaptor.Controller.DI; | |
3 | 3 | |
4 | 4 | namespace CleanAuLait.Adaptor.Controller |
5 | 5 | { |
@@ -15,9 +15,7 @@ | ||
15 | 15 | |
16 | 16 | <ItemGroup> |
17 | 17 | <PackageReference Include="AutoMapper" Version="11.0.1" /> |
18 | - <PackageReference Include="Microsoft-WindowsAPICodePack-Shell" Version="1.1.5" /> | |
19 | 18 | <PackageReference Include="NLog" Version="5.0.1" /> |
20 | - <PackageReference Include="Prism.Core" Version="8.1.97" /> | |
21 | 19 | <PackageReference Include="ReactiveProperty" Version="8.1.2" /> |
22 | 20 | </ItemGroup> |
23 | 21 |
@@ -1,36 +0,0 @@ | ||
1 | -using CleanAuLait.Core.DI; | |
2 | -using CleanAuLait.Core.Resource; | |
3 | -using NLog; | |
4 | -using Prism.Ioc; | |
5 | -using Prism.Modularity; | |
6 | - | |
7 | -namespace CleanAuLait | |
8 | -{ | |
9 | - public class CleanAuLaitModule: IModule | |
10 | - { | |
11 | - private static readonly ILogger logger = LogManager.GetCurrentClassLogger(); | |
12 | - | |
13 | - public void RegisterTypes(IContainerRegistry containerRegistry) | |
14 | - { | |
15 | - // | |
16 | - // Controller | |
17 | - // | |
18 | - | |
19 | - containerRegistry.RegisterSingleton<IRequestScopeGenerator, RequestScopeGenerator>(); | |
20 | - | |
21 | - /// | |
22 | - /// Resources | |
23 | - /// | |
24 | - | |
25 | - containerRegistry.RegisterSingleton<ICaptionFormatter, CaptionFormatter>(); | |
26 | - | |
27 | - logger.Trace("RegisterTypes end"); | |
28 | - } | |
29 | - | |
30 | - public void OnInitialized(IContainerProvider containerProvider) | |
31 | - { | |
32 | - // NOP | |
33 | - } | |
34 | - | |
35 | - } | |
36 | -} | |
\ No newline at end of file |
@@ -3,7 +3,7 @@ | ||
3 | 3 | namespace CleanAuLait.Core.DI |
4 | 4 | { |
5 | 5 | [Serializable] |
6 | - internal class DIException : Exception | |
6 | + public class DIException : Exception | |
7 | 7 | { |
8 | 8 | public DIException() |
9 | 9 | { |
@@ -1,9 +0,0 @@ | ||
1 | -using Prism.Ioc; | |
2 | - | |
3 | -namespace CleanAuLait.Core.DI | |
4 | -{ | |
5 | - public interface IRequestScopeGenerator | |
6 | - { | |
7 | - IScopedProvider CreateScope(); | |
8 | - } | |
9 | -} | |
\ No newline at end of file |
@@ -1,24 +0,0 @@ | ||
1 | -using Prism.Ioc; | |
2 | - | |
3 | -namespace CleanAuLait.Core.DI | |
4 | -{ | |
5 | - public class RequestScopeGenerator : IRequestScopeGenerator | |
6 | - { | |
7 | - public IScopedProvider CreateScope() | |
8 | - { | |
9 | - try | |
10 | - { | |
11 | - return GetContainer().CreateScope(); | |
12 | - } | |
13 | - catch (Exception e) | |
14 | - { | |
15 | - throw new DIException(e); | |
16 | - } | |
17 | - } | |
18 | - | |
19 | - protected virtual IContainerProvider GetContainer() | |
20 | - { | |
21 | - return ContainerLocator.Container; | |
22 | - } | |
23 | - } | |
24 | -} |