• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Aucun tag

Frequently used words (click to add to your profile)

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

Commit MetaInfo

Révision99efaf47f529bc749e009fddbc3b0dee6cd7e992 (tree)
l'heure2022-08-12 00:19:33
Auteuryoshy <yoshy.org.bitbucket@gz.j...>
Commiteryoshy

Message de Log

initial revision.
CleanAuLait から Prism 関連の実装を分離

Change Summary

Modification

--- /dev/null
+++ b/Adaptor/Controller/AsyncHandlerContextFactoryRegistrar.cs
@@ -0,0 +1,24 @@
1+using CleanAuLait.Adaptor.Boundary.Controller;
2+using Prism.Ioc;
3+
4+namespace CleanAuLait.Adaptor.Controller
5+{
6+ public class AsyncHandlerContextFactoryRegistrar :
7+ AbstractHandlerContextFactoryRegistrar<IAsyncHandlerContextFactory, AsyncHandlerContextFactory>
8+ {
9+ private readonly IContainerRegistry containerRegistry;
10+
11+ public AsyncHandlerContextFactoryRegistrar(IContainerRegistry containerRegistry)
12+ {
13+ this.containerRegistry = containerRegistry;
14+ }
15+
16+ public override void Register()
17+ {
18+ var factory = CreateFactoryFactory();
19+
20+ this.containerRegistry.RegisterSingleton<IAsyncHandlerContextFactory>(factory);
21+ }
22+
23+ }
24+}
--- /dev/null
+++ b/Adaptor/Controller/DI/RequestScopeGenerator.cs
@@ -0,0 +1,25 @@
1+using CleanAuLait.Core.DI;
2+using Prism.Ioc;
3+
4+namespace CleanAuLait.Adaptor.Controller.DI
5+{
6+ internal class RequestScopeGenerator : IRequestScopeGenerator
7+ {
8+ public IRequestScopedProvider CreateScope()
9+ {
10+ try
11+ {
12+ return new RequestScopedProvider(GetContainer().CreateScope());
13+ }
14+ catch (Exception e)
15+ {
16+ throw new DIException(e);
17+ }
18+ }
19+
20+ protected virtual IContainerProvider GetContainer()
21+ {
22+ return ContainerLocator.Container;
23+ }
24+ }
25+}
--- /dev/null
+++ b/Adaptor/Controller/DI/RequestScopedProvider.cs
@@ -0,0 +1,32 @@
1+using CleanAuLait.Core.DI;
2+using Prism.Ioc;
3+
4+namespace CleanAuLait.Adaptor.Controller.DI;
5+
6+internal class RequestScopedProvider : IRequestScopedProvider
7+{
8+ private readonly IScopedProvider scopedProvider;
9+
10+ public RequestScopedProvider(IScopedProvider scopedProvider)
11+ {
12+ this.scopedProvider = scopedProvider;
13+ }
14+
15+ public object Resolve(Type type)
16+ {
17+ try
18+ {
19+ return this.scopedProvider.Resolve(type);
20+ }
21+ catch (ContainerResolutionException e)
22+ {
23+ throw new DIException(e);
24+ }
25+ }
26+
27+ public void Dispose()
28+ {
29+ this.scopedProvider?.Dispose();
30+ }
31+
32+}
\ No newline at end of file
--- /dev/null
+++ b/Adaptor/Controller/HandlerContextFactoryRegistrar.cs
@@ -0,0 +1,23 @@
1+using CleanAuLait.Adaptor.Boundary.Controller;
2+using Prism.Ioc;
3+
4+namespace CleanAuLait.Adaptor.Controller
5+{
6+ public class HandlerContextFactoryRegistrar :
7+ AbstractHandlerContextFactoryRegistrar<IHandlerContextFactory, HandlerContextFactory>
8+ {
9+ private readonly IContainerRegistry containerRegistry;
10+
11+ public HandlerContextFactoryRegistrar(IContainerRegistry containerRegistry)
12+ {
13+ this.containerRegistry = containerRegistry;
14+ }
15+
16+ public override void Register()
17+ {
18+ var factory = CreateFactoryFactory();
19+
20+ this.containerRegistry.RegisterSingleton<IHandlerContextFactory>(factory);
21+ }
22+ }
23+}
--- /dev/null
+++ b/CleanAuLait.Prism.csproj
@@ -0,0 +1,17 @@
1+<Project Sdk="Microsoft.NET.Sdk">
2+
3+ <PropertyGroup>
4+ <TargetFramework>net6.0-windows10.0.19041.0</TargetFramework>
5+ <ImplicitUsings>enable</ImplicitUsings>
6+ <Nullable>enable</Nullable>
7+ </PropertyGroup>
8+
9+ <ItemGroup>
10+ <PackageReference Include="Prism.Core" Version="8.1.97" />
11+ </ItemGroup>
12+
13+ <ItemGroup>
14+ <ProjectReference Include="..\CleanAuLait\CleanAuLait.csproj" />
15+ </ItemGroup>
16+
17+</Project>
--- /dev/null
+++ b/CleanAuLaitPrismModule.cs
@@ -0,0 +1,36 @@
1+using CleanAuLait.Adaptor.Controller.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 CleanAuLaitPrismModule : 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