• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Keine Tags

Frequently used words (click to add to your profile)

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

Commit MetaInfo

Revision86e26ecde9d36b0074e6fb8a2a2b26250bb81d51 (tree)
Zeit2022-11-30 01:06:13
Autoryoshy <yoshy.org.bitbucket@gz.j...>
Commiteryoshy

Log Message

[MOD] UserDialogProxy の名前空間を UI 配下から UI.Dialog 配下に移動
[FIX] JsonHelper.ToJsonString のメソッド名が破損していた不具合を修正
[MOD] キャプション書式化機能でキャプションの取得と書式化を行う機能の区別を明確にした
[MOD] MessageRepository の基底処理を CleanAuLait 側と同様に AbstractMessageRepository クラスに分割
[ADD] CleanAuLait 側で追加された機能の取り込み(PathHelper, DateTimeHelper, ログ系)

Ändern Zusammenfassung

Diff

--- /dev/null
+++ b/Adaptor/Boundary/Gateway/UI/Dialog/IUserDialogProxy.cs
@@ -0,0 +1,19 @@
1+using System;
2+using System.Windows;
3+
4+namespace CleanAuLait48.Adaptor.Boundary.Gateway.UI.Dialog
5+{
6+ public interface IUserDialogProxy
7+ {
8+ void ShowInfo(string msg);
9+ void ShowInfo(string msg, string captionKey);
10+ void ShowWarn(string msg);
11+ void ShowWarn(string msg, string captionKey);
12+ void ShowError(Exception e);
13+ void ShowError(Exception e, string captionKey);
14+ void ShowError(string msg);
15+ void ShowError(string msg, string captionKey);
16+ MessageBoxResult ShowConfirm(string msg);
17+ MessageBoxResult ShowConfirm(string msg, string captionKey);
18+ }
19+}
\ No newline at end of file
--- a/Adaptor/Boundary/Gateway/UI/IUserDialogProxy.cs
+++ /dev/null
@@ -1,17 +0,0 @@
1-using CleanAuLait48.Adaptor.Gateway.UI;
2-using System;
3-
4-namespace CleanAuLait48.Adaptor.Boundary.Gateway.UI
5-{
6- public interface IUserDialogProxy
7- {
8- void ShowInfo(string msg);
9- void ShowInfo(string msg, DlgInfo uiInfo);
10- void ShowWarn(string msg);
11- void ShowWarn(string msg, DlgInfo uiInfo);
12- void ShowError(Exception e);
13- void ShowError(Exception e, DlgInfo uiInfo);
14- void ShowError(string msg);
15- void ShowError(string msg, DlgInfo uiInfo);
16- }
17-}
\ No newline at end of file
--- a/Adaptor/Controller/Handler/AbstractErrorHandler.cs
+++ b/Adaptor/Controller/Handler/AbstractErrorHandler.cs
@@ -1,4 +1,4 @@
1-using CleanAuLait48.Adaptor.Boundary.Gateway.UI;
1+using CleanAuLait48.Adaptor.Boundary.Gateway.UI.Dialog;
22 using CleanAuLait48.UseCase.Request;
33 using CleanAuLait48.UseCase.Response;
44
--- a/Adaptor/Controller/Handler/AsyncSimpleUserDialogErrorHandler.cs
+++ b/Adaptor/Controller/Handler/AsyncSimpleUserDialogErrorHandler.cs
@@ -1,6 +1,6 @@
11 using CleanAuLait48.Adaptor.Boundary.Controller;
22 using CleanAuLait48.Adaptor.Boundary.Controller.Handler;
3-using CleanAuLait48.Adaptor.Boundary.Gateway.UI;
3+using CleanAuLait48.Adaptor.Boundary.Gateway.UI.Dialog;
44 using CleanAuLait48.UseCase.Request;
55 using CleanAuLait48.UseCase.Response;
66 using NLog;
--- a/Adaptor/Controller/Handler/SimpleErrorHandler.cs
+++ b/Adaptor/Controller/Handler/SimpleErrorHandler.cs
@@ -1,6 +1,6 @@
11 using CleanAuLait48.Adaptor.Boundary.Controller;
22 using CleanAuLait48.Adaptor.Boundary.Controller.Handler;
3-using CleanAuLait48.Adaptor.Boundary.Gateway.UI;
3+using CleanAuLait48.Adaptor.Boundary.Gateway.UI.Dialog;
44 using CleanAuLait48.UseCase.Request;
55 using CleanAuLait48.UseCase.Response;
66 using NLog;
--- /dev/null
+++ b/Adaptor/Gateway/UI/Dialog/UserDialogProxy.cs
@@ -0,0 +1,92 @@
1+using CleanAuLait48.Adaptor.Boundary.Gateway.UI.Dialog;
2+using CleanAuLait48.Core.Resource;
3+using System;
4+using System.Windows;
5+
6+namespace CleanAuLait48.Adaptor.Gateway.UI.Dialog
7+{
8+ public class UserDialogProxy : IUserDialogProxy
9+ {
10+ private readonly ICaptionFormatter captionFormatter;
11+
12+ public UserDialogProxy(ICaptionFormatter captionFormatter)
13+ {
14+ this.captionFormatter = captionFormatter;
15+ }
16+
17+ public void ShowInfo(string msg)
18+ {
19+ ShowInfo(msg, null);
20+ }
21+
22+ public void ShowInfo(string msg, string captionKey)
23+ {
24+ string caption = this.captionFormatter.FormatInfoCaption(captionKey);
25+ MessageBoxImage icon = MessageBoxImage.Information;
26+
27+ ShowNotify(caption, msg, icon);
28+ }
29+
30+ public void ShowWarn(string msg)
31+ {
32+ ShowWarn(msg, null);
33+ }
34+
35+ public void ShowWarn(string msg, string captionKey)
36+ {
37+ string caption = this.captionFormatter.FormatWarnCaption(captionKey);
38+ MessageBoxImage icon = MessageBoxImage.Warning;
39+
40+ ShowNotify(caption, msg, icon);
41+ }
42+
43+ public void ShowError(Exception e)
44+ {
45+ ShowError(e, null);
46+ }
47+
48+ public void ShowError(Exception e, string captionKey)
49+ {
50+ string caption = this.captionFormatter.FormatExceptionCaption(e, captionKey);
51+ MessageBoxImage icon = MessageBoxImage.Error;
52+
53+ ShowNotify(caption, e.Message, icon);
54+ }
55+
56+ public void ShowError(string msg)
57+ {
58+ ShowError(msg, null);
59+ }
60+
61+ public void ShowError(string msg, string captionKey)
62+ {
63+ string caption = this.captionFormatter.FormatErrorCaption(captionKey);
64+ MessageBoxImage icon = MessageBoxImage.Error;
65+
66+ ShowNotify(caption, msg, icon);
67+ }
68+
69+ public static void ShowNotify(string caption, string msg, MessageBoxImage icon)
70+ {
71+ MessageBox.Show(msg, caption, MessageBoxButton.OK, icon);
72+ }
73+
74+ public MessageBoxResult ShowConfirm(string msg)
75+ {
76+ return ShowConfirm(msg, null);
77+ }
78+
79+ public MessageBoxResult ShowConfirm(string msg, string captionKey)
80+ {
81+ string caption = this.captionFormatter.FormatConfirmCaption(captionKey);
82+ MessageBoxImage icon = MessageBoxImage.Question;
83+
84+ return ShowConfirm(caption, msg, icon);
85+ }
86+
87+ public static MessageBoxResult ShowConfirm(string caption, string msg, MessageBoxImage icon)
88+ {
89+ return MessageBox.Show(msg, caption, MessageBoxButton.YesNo, icon);
90+ }
91+ }
92+}
--- a/Adaptor/Gateway/UI/DlgInfo.cs
+++ /dev/null
@@ -1,16 +0,0 @@
1-namespace CleanAuLait48.Adaptor.Gateway.UI
2-{
3- public class DlgInfo
4- {
5- public string Caption { get; protected set; } = string.Empty;
6-
7- protected DlgInfo()
8- {
9- }
10-
11- public DlgInfo(string caption)
12- {
13- Caption = caption;
14- }
15- }
16-}
--- a/Adaptor/Gateway/UserDialogProxy.cs
+++ /dev/null
@@ -1,74 +0,0 @@
1-using CleanAuLait48.Adaptor.Boundary.Gateway.UI;
2-using CleanAuLait48.Core.Resource;
3-using System;
4-using System.Windows.Forms;
5-
6-namespace CleanAuLait48.Adaptor.Gateway.UI
7-{
8- public class UserDialogProxy : IUserDialogProxy
9- {
10- private readonly ICaptionFormatter captionFormatter;
11-
12- public UserDialogProxy(ICaptionFormatter captionFormatter)
13- {
14- this.captionFormatter = captionFormatter;
15- }
16-
17- public void ShowInfo(string msg)
18- {
19- ShowInfo(msg, null);
20- }
21-
22- public void ShowInfo(string msg, DlgInfo uiInfo)
23- {
24- string caption = captionFormatter.GetInfoCaption(uiInfo);
25- MessageBoxIcon icon = MessageBoxIcon.Information;
26-
27- ShowNotify(caption, msg, icon);
28- }
29-
30- public void ShowWarn(string msg)
31- {
32- ShowWarn(msg, null);
33- }
34-
35- public void ShowWarn(string msg, DlgInfo uiInfo)
36- {
37- string caption = captionFormatter.GetWarnCaption(uiInfo);
38- MessageBoxIcon icon = MessageBoxIcon.Warning;
39-
40- ShowNotify(caption, msg, icon);
41- }
42-
43- public void ShowError(Exception e)
44- {
45- ShowError(e, null);
46- }
47-
48- public void ShowError(Exception e, DlgInfo uiInfo)
49- {
50- string caption = captionFormatter.GetExceptionCaption(e, uiInfo);
51- MessageBoxIcon icon = MessageBoxIcon.Error;
52-
53- ShowNotify(caption, e.Message, icon);
54- }
55-
56- public void ShowError(string msg)
57- {
58- ShowError(msg, null);
59- }
60-
61- public void ShowError(string msg, DlgInfo uiInfo)
62- {
63- string caption = captionFormatter.GetErrorCaption(uiInfo);
64- MessageBoxIcon icon = MessageBoxIcon.Error;
65-
66- ShowNotify(caption, msg, icon);
67- }
68-
69- public static void ShowNotify(string caption, string msg, MessageBoxIcon icon)
70- {
71- MessageBox.Show(msg, caption, MessageBoxButtons.OK, icon);
72- }
73- }
74-}
--- a/CleanAuLait48.csproj
+++ b/CleanAuLait48.csproj
@@ -33,6 +33,7 @@
3333 <WarningLevel>4</WarningLevel>
3434 </PropertyGroup>
3535 <ItemGroup>
36+ <Reference Include="PresentationFramework" />
3637 <Reference Include="System" />
3738 <Reference Include="System.ComponentModel" />
3839 <Reference Include="System.ComponentModel.DataAnnotations" />
@@ -75,7 +76,7 @@
7576 <Compile Include="Adaptor\Boundary\Controller\Router\IAsyncUseCaseRouterAwareInteractor.cs" />
7677 <Compile Include="Adaptor\Boundary\Controller\Router\IUseCaseRouter.cs" />
7778 <Compile Include="Adaptor\Boundary\Controller\Router\IUseCaseRouterAwareInteractor.cs" />
78- <Compile Include="Adaptor\Boundary\Gateway\UI\IUserDialogProxy.cs" />
79+ <Compile Include="Adaptor\Boundary\Gateway\UI\Dialog\IUserDialogProxy.cs" />
7980 <Compile Include="Adaptor\Controller\AsyncHandlerContextFactory.cs" />
8081 <Compile Include="Adaptor\Controller\HandlerContextFactory.cs" />
8182 <Compile Include="Adaptor\Controller\Handler\AbstractErrorHandler.cs" />
@@ -86,8 +87,7 @@
8687 <Compile Include="Adaptor\Controller\Router\AbstractUseCaseRouter.cs" />
8788 <Compile Include="Adaptor\Controller\Router\AsyncUseCaseRouter.cs" />
8889 <Compile Include="Adaptor\Controller\Router\UseCaseRouter.cs" />
89- <Compile Include="Adaptor\Gateway\UI\DlgInfo.cs" />
90- <Compile Include="Adaptor\Gateway\UserDialogProxy.cs" />
90+ <Compile Include="Adaptor\Gateway\UI\Dialog\UserDialogProxy.cs" />
9191 <Compile Include="CleanAuLait48Const.cs" />
9292 <Compile Include="Core\Async\AbstractCancellationTokenProvider.cs" />
9393 <Compile Include="Core\Async\CancellationTokenManager.cs" />
@@ -116,9 +116,16 @@
116116 <Compile Include="Core\DI\SimpleInjector\SimpleInjectorComponentProvider.cs" />
117117 <Compile Include="Core\DI\SimpleInjector\SimpleInjectorComponentRegistry.cs" />
118118 <Compile Include="Core\Event\EventWrapper.cs" />
119- <Compile Include="Core\Helper\DateTimeHelper.cs" />
119+ <Compile Include="Core\Log\AsyncOnLogTarget.cs" />
120+ <Compile Include="Core\Log\IAsyncOnLogTarget.cs" />
121+ <Compile Include="Core\Log\IOnLogTarget.cs" />
122+ <Compile Include="Core\Log\OnLogTarget.cs" />
123+ <Compile Include="Core\Log\SimpleLoggerLayoutRenderer.cs" />
124+ <Compile Include="Core\Time\DateTimeHelper.cs" />
120125 <Compile Include="Core\Converter\JsonHelper.cs" />
126+ <Compile Include="Core\IO\PathHelper.cs" />
121127 <Compile Include="Core\Log\LogHelper.cs" />
128+ <Compile Include="Core\Resource\AbstractMessageRepository.cs" />
122129 <Compile Include="Core\Resource\IMessageRepository.cs" />
123130 <Compile Include="Core\Resource\MessageRepository.cs" />
124131 <Compile Include="Core\Resource\ResourceHelper.cs" />
@@ -134,7 +141,6 @@
134141 <Compile Include="UseCase\Boundary\Interactor\IUseCaseRouterAware.cs" />
135142 <Compile Include="UseCase\Boundary\Presenter\IAsyncPresenter.cs" />
136143 <Compile Include="UseCase\Boundary\Presenter\IPresenter.cs" />
137- <Compile Include="UseCase\Request\UIUseCaseRequest.cs" />
138144 <Compile Include="UseCase\Request\UseCaseRequest.cs" />
139145 <Compile Include="UseCase\Response\UseCaseResponse.cs" />
140146 <Compile Include="UseCase\Response\UseCaseResultTypes.cs" />
@@ -150,5 +156,6 @@
150156 <Version>5.3.3</Version>
151157 </PackageReference>
152158 </ItemGroup>
159+ <ItemGroup />
153160 <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
154161 </Project>
\ No newline at end of file
--- a/Core/Converter/JsonHelper.cs
+++ b/Core/Converter/JsonHelper.cs
@@ -7,7 +7,7 @@ namespace CleanAuLait48.Core.Converter
77 /// <see href="https://mokake.hatenablog.com/entry/2017/09/12/195656">
88 public static class JsonHelper
99 {
10- public static string ToJToJsonStringson<T>(this T data)
10+ public static string ToJsonString<T>(this T data)
1111 {
1212 using (var stream = new MemoryStream())
1313 {
--- /dev/null
+++ b/Core/IO/PathHelper.cs
@@ -0,0 +1,48 @@
1+using System.IO;
2+using System.Linq;
3+
4+namespace CleanAuLait48.Core.IO
5+{
6+ public static class PathHelper
7+ {
8+ public static readonly string RELATIVE_PATH_CURRENT = ".";
9+ public static readonly string RELATIVE_PATH_UPWARDS = "..";
10+
11+ public static string CreateCanonicalPath(params string[] paths)
12+ {
13+ if (paths.Any(path => string.IsNullOrEmpty(path)))
14+ {
15+ return null;
16+ }
17+
18+ return CreateCanonicalPath(Path.Combine(paths));
19+ }
20+
21+ public static string CreateCanonicalPath(string path)
22+ {
23+ if (string.IsNullOrEmpty(path))
24+ {
25+ return null;
26+ }
27+
28+ return Path.GetFullPath(path);
29+ }
30+
31+ public static string EnsureLeadingDotPath(string relativePath)
32+ {
33+ return relativePath == RELATIVE_PATH_CURRENT
34+ ? relativePath
35+ : Path.Combine(RELATIVE_PATH_CURRENT, relativePath);
36+ }
37+
38+ public static string EnsureEndingDirectorySeparator(string path)
39+ {
40+ if (!path.EndsWith(Path.DirectorySeparatorChar.ToString()))
41+ {
42+ return path + Path.DirectorySeparatorChar;
43+ }
44+
45+ return path;
46+ }
47+ }
48+}
--- /dev/null
+++ b/Core/Log/AsyncOnLogTarget.cs
@@ -0,0 +1,127 @@
1+using NLog;
2+using NLog.Config;
3+using NLog.Targets;
4+using NLog.Targets.Wrappers;
5+using System;
6+using System.Collections.Generic;
7+using System.Text;
8+using System.Threading;
9+using System.Threading.Tasks;
10+
11+namespace CleanAuLait48.Core.Log
12+{
13+ public class AsyncOnLogTarget : AsyncTaskTarget, IAsyncOnLogTarget
14+ {
15+ public event EventHandler<string> OnLog;
16+
17+ private LoggingRule loggingRule;
18+ private bool isClosed;
19+
20+ public AsyncOnLogTarget(string name, string minLevel) : this(name, ParseLogLevel(minLevel, LogLevel.Info))
21+ {
22+ }
23+
24+ public AsyncOnLogTarget(string name, LogLevel minLevel)
25+ {
26+ this.BatchSize = 10;
27+ this.TaskDelayMilliseconds = 200;
28+ this.QueueLimit = 10000;
29+ this.OverflowAction = AsyncTargetWrapperOverflowAction.Discard;
30+
31+ // important: we want LogManager.Configuration property assign behaviors \ magic to occur
32+ // see: https://stackoverflow.com/a/3603571/1366179
33+ var config = LogManager.Configuration;
34+
35+ // Add Target and Rule to their respective collections
36+ config.AddTarget(name, this);
37+
38+ this.loggingRule = new LoggingRule("*", minLevel, LogLevel.Fatal, this);
39+ config.LoggingRules.Add(this.loggingRule);
40+
41+ LogManager.Configuration = config;
42+ }
43+
44+ public void ChangeMinLogLevel(string minLevel)
45+ {
46+ var config = LogManager.Configuration;
47+
48+ this.loggingRule.Targets.Remove(this);
49+ config.LoggingRules.Remove(this.loggingRule);
50+
51+ this.loggingRule = new LoggingRule("*", ParseLogLevel(minLevel, LogLevel.Info), LogLevel.Fatal, this);
52+
53+ config.LoggingRules.Add(this.loggingRule);
54+
55+ LogManager.Configuration = config;
56+ }
57+
58+ private static LogLevel ParseLogLevel(string level, LogLevel dafaultValue)
59+ {
60+ try
61+ {
62+ return !string.IsNullOrEmpty(level) ? LogLevel.FromString(level) : dafaultValue;
63+ }
64+ catch
65+ {
66+ return default;
67+ }
68+ }
69+
70+ public void Close()
71+ {
72+ isClosed = true;
73+
74+ var config = LogManager.Configuration;
75+
76+ this.loggingRule.Targets.Remove(this);
77+ config.LoggingRules.Remove(this.loggingRule);
78+
79+ LogManager.Configuration = config;
80+ }
81+
82+ protected override Task WriteAsyncTask(LogEventInfo logEvent, CancellationToken cancellationToken)
83+ {
84+ return Task.Run(() =>
85+ {
86+ if (isClosed)
87+ {
88+ return;
89+ }
90+
91+ string msg = Layout.Render(logEvent);
92+
93+ if (cancellationToken.IsCancellationRequested)
94+ {
95+ return;
96+ }
97+
98+ OnLog(this, msg);
99+
100+ }, cancellationToken);
101+ }
102+
103+ protected override Task WriteAsyncTask(IList<LogEventInfo> logEvents, CancellationToken cancellationToken)
104+ {
105+ return Task.Run(() =>
106+ {
107+ if (isClosed)
108+ {
109+ return;
110+ }
111+
112+ StringBuilder buf = new StringBuilder();
113+ foreach (var logEvent in logEvents)
114+ {
115+ buf.AppendLine(Layout.Render(logEvent));
116+ }
117+
118+ if (cancellationToken.IsCancellationRequested)
119+ {
120+ return;
121+ }
122+
123+ OnLog(this, buf.ToString());
124+ }, cancellationToken);
125+ }
126+ }
127+}
--- /dev/null
+++ b/Core/Log/IAsyncOnLogTarget.cs
@@ -0,0 +1,11 @@
1+using System;
2+
3+namespace CleanAuLait48.Core.Log
4+{
5+ public interface IAsyncOnLogTarget
6+ {
7+ event EventHandler<string> OnLog;
8+ void ChangeMinLogLevel(string minLevel);
9+ void Close();
10+ }
11+}
\ No newline at end of file
--- /dev/null
+++ b/Core/Log/IOnLogTarget.cs
@@ -0,0 +1,11 @@
1+using System;
2+
3+namespace CleanAuLait48.Core.Log
4+{
5+ public interface IOnLogTarget
6+ {
7+ event EventHandler<string> OnLog;
8+ void ChangeMinLogLevel(string minLevel);
9+ void Close();
10+ }
11+}
\ No newline at end of file
--- /dev/null
+++ b/Core/Log/OnLogTarget.cs
@@ -0,0 +1,127 @@
1+using NLog;
2+using NLog.Common;
3+using NLog.Config;
4+using NLog.Targets;
5+using NLog.Targets.Wrappers;
6+using System;
7+using System.Collections.Generic;
8+using System.Text;
9+
10+namespace CleanAuLait48.Core.Log
11+{
12+ public class OnLogTarget : TargetWithLayout, IOnLogTarget
13+ {
14+ public event EventHandler<string> OnLog;
15+
16+ private LoggingRule loggingRule;
17+ private bool isClosed;
18+
19+ private readonly object objLock = new object();
20+
21+ public OnLogTarget(string name, string minLevel)
22+ {
23+ // important: we want LogManager.Configuration property assign behaviors \ magic to occur
24+ // see: https://stackoverflow.com/a/3603571/1366179
25+ var config = LogManager.Configuration;
26+
27+ Target target = new AsyncTargetWrapper(this, 8192, AsyncTargetWrapperOverflowAction.Discard);
28+
29+ // Add Target and Rule to their respective collections
30+ config.AddTarget(name, target);
31+
32+ this.loggingRule = new LoggingRule("*", ParseLogLevel(minLevel, LogLevel.Info), LogLevel.Fatal, this);
33+ config.LoggingRules.Add(this.loggingRule);
34+
35+ LogManager.Configuration = config;
36+ }
37+
38+ public void ChangeMinLogLevel(string minLevel)
39+ {
40+ var config = LogManager.Configuration;
41+
42+ this.loggingRule.Targets.Remove(this);
43+ config.LoggingRules.Remove(this.loggingRule);
44+
45+ this.loggingRule = new LoggingRule("*", ParseLogLevel(minLevel, LogLevel.Info), LogLevel.Fatal, this);
46+
47+ config.LoggingRules.Add(this.loggingRule);
48+
49+ LogManager.Configuration = config;
50+ }
51+
52+ private static LogLevel ParseLogLevel(string level, LogLevel dafaultValue)
53+ {
54+ try
55+ {
56+ return !string.IsNullOrEmpty(level) ? LogLevel.FromString(level) : dafaultValue;
57+ }
58+ catch
59+ {
60+ return default;
61+ }
62+ }
63+
64+ public void Close()
65+ {
66+ isClosed = true;
67+
68+ var config = LogManager.Configuration;
69+
70+ this.loggingRule.Targets.Remove(this);
71+ config.LoggingRules.Remove(this.loggingRule);
72+
73+ LogManager.Configuration = config;
74+ }
75+
76+ protected override void Write(LogEventInfo logEvent)
77+ {
78+ if (isClosed)
79+ {
80+ return;
81+ }
82+
83+ string msg = Layout.Render(logEvent);
84+
85+ OnLog(this, msg);
86+ }
87+
88+ protected override void Write(AsyncLogEventInfo logEvent)
89+ {
90+ Write(logEvent.LogEvent);
91+ }
92+
93+ protected override void WriteAsyncThreadSafe(AsyncLogEventInfo logEvent)
94+ {
95+ lock (objLock)
96+ {
97+ Write(logEvent);
98+ }
99+ }
100+
101+ protected override void Write(IList<AsyncLogEventInfo> logEvents)
102+ {
103+ StringBuilder buf = new StringBuilder();
104+
105+ foreach (AsyncLogEventInfo logEvent in logEvents)
106+ {
107+ buf.AppendLine(Layout.Render(logEvent.LogEvent));
108+ }
109+
110+ OnLog(this, buf.ToString());
111+ }
112+
113+ protected override void WriteAsyncThreadSafe(IList<AsyncLogEventInfo> logEvents)
114+ {
115+ lock (objLock)
116+ {
117+ if (isClosed)
118+ {
119+ return;
120+ }
121+
122+ Write(logEvents);
123+ }
124+ }
125+
126+ }
127+}
--- /dev/null
+++ b/Core/Log/SimpleLoggerLayoutRenderer.cs
@@ -0,0 +1,17 @@
1+using NLog;
2+using NLog.LayoutRenderers;
3+using System.Text;
4+
5+namespace CleanAuLait48.Core.Log
6+{
7+ public class SimpleLoggerLayoutRenderer : LayoutRenderer
8+ {
9+ protected override void Append(StringBuilder builder, LogEventInfo logEvent)
10+ {
11+ string loggerName = logEvent.LoggerName;
12+ string simpleLoggerName = loggerName.Substring(loggerName.LastIndexOf('.') + 1);
13+
14+ builder.Append(simpleLoggerName);
15+ }
16+ }
17+}
--- /dev/null
+++ b/Core/Resource/AbstractMessageRepository.cs
@@ -0,0 +1,42 @@
1+using System.Collections.Generic;
2+
3+namespace CleanAuLait48.Core.Resource
4+{
5+ public abstract class AbstractMessageRepository : IMessageRepository
6+ {
7+ protected readonly IDictionary<string, string> map = new Dictionary<string, string>();
8+
9+ protected virtual void RegisterMessages(string properties)
10+ {
11+ string[] lines = properties.Split('\n');
12+
13+ foreach (string line in lines)
14+ {
15+ if (line.StartsWith("#") || (line.Trim().Length == 0))
16+ {
17+ continue;
18+ }
19+
20+ string[] data = line.Split('=');
21+ map.Add(data[0].Trim(), data[1].Trim());
22+ }
23+ }
24+
25+ public virtual string Get(string key)
26+ {
27+ return GetMap()[key];
28+ }
29+
30+ public virtual string Get(string key, params string[] args)
31+ {
32+ string msg = GetMap()[key];
33+
34+ return string.Format(msg, args);
35+ }
36+
37+ public virtual IDictionary<string, string> GetMap()
38+ {
39+ return map;
40+ }
41+ }
42+}
--- a/Core/Resource/CaptionFormatter.cs
+++ b/Core/Resource/CaptionFormatter.cs
@@ -6,86 +6,116 @@ namespace CleanAuLait48.Core.Resource
66 public class CaptionFormatter : ICaptionFormatter
77 {
88 public const string MSG_KEY_CAPTION = "Caption";
9- public const string MSG_KEY_CAPTION_INFO = "Caption.Info";
10- public const string MSG_KEY_CAPTION_WARN = "Caption.Warn";
11- public const string MSG_KEY_CAPTION_ERROR = "Caption.Error";
12- public const string MSG_KEY_CAPTION_EXCEPTION = "Caption.Exception";
13-
9+
10+ public const string MSG_KEY_PREFIX_CAPTION_FORMAT = "Caption.Format.";
11+
12+ public const string MSG_KEY_CAPTION_FORMAT_INFO = MSG_KEY_PREFIX_CAPTION_FORMAT + "Info";
13+ public const string MSG_KEY_CAPTION_FORMAT_WARN = MSG_KEY_PREFIX_CAPTION_FORMAT + "Warn";
14+ public const string MSG_KEY_CAPTION_FORMAT_ERROR = MSG_KEY_PREFIX_CAPTION_FORMAT + "Error";
15+ public const string MSG_KEY_CAPTION_FORMAT_CONFIRM = MSG_KEY_PREFIX_CAPTION_FORMAT + "Confirm";
16+ public const string MSG_KEY_CAPTION_FORMAT_EXCEPTION = MSG_KEY_PREFIX_CAPTION_FORMAT + "Exception";
17+
1418 protected readonly IMessageRepository repo;
15- protected readonly DlgInfo defaultDlgInfo;
1619
1720 public CaptionFormatter(IMessageRepository repo)
1821 {
1922 this.repo = repo;
20- this.defaultDlgInfo = new DlgInfo(GetCaption());
2123 }
2224
23- public string GetCaption()
25+ public string GetDefaultCaption()
2426 {
25- return repo.Get(MSG_KEY_CAPTION);
27+ return GetCaption(MSG_KEY_CAPTION);
2628 }
2729
28- public DlgInfo GetDefaultDlgInfo()
30+ public string GetCaption(string captionKey)
2931 {
30- return defaultDlgInfo;
32+ return this.repo.Get(captionKey);
3133 }
3234
3335 public string GetInfoCaption()
3436 {
35- return GetCaption(MSG_KEY_CAPTION_INFO);
37+ return FormatDefaultCaption(MSG_KEY_CAPTION_FORMAT_INFO);
3638 }
3739
38- public string GetInfoCaption(DlgInfo dlgInfo)
40+ public string FormatInfoCaption(string captionKey)
3941 {
40- return GetCaption(MSG_KEY_CAPTION_INFO, dlgInfo);
42+ return FormatCaption(MSG_KEY_CAPTION_FORMAT_INFO, captionKey);
4143 }
4244
4345 public string GetWarnCaption()
4446 {
45- return GetCaption(MSG_KEY_CAPTION_WARN);
47+ return FormatDefaultCaption(MSG_KEY_CAPTION_FORMAT_WARN);
4648 }
4749
48- public string GetWarnCaption(DlgInfo dlgInfo)
50+ public string FormatWarnCaption(string captionKey)
4951 {
50- return GetCaption(MSG_KEY_CAPTION_WARN, dlgInfo);
52+ return FormatCaption(MSG_KEY_CAPTION_FORMAT_WARN, captionKey);
5153 }
5254
5355 public string GetErrorCaption()
5456 {
55- return GetCaption(MSG_KEY_CAPTION_ERROR);
57+ return FormatDefaultCaption(MSG_KEY_CAPTION_FORMAT_ERROR);
58+ }
59+
60+ public string FormatErrorCaption(string captionKey)
61+ {
62+ return FormatCaption(MSG_KEY_CAPTION_FORMAT_ERROR, captionKey);
5663 }
5764
58- public string GetErrorCaption(DlgInfo dlgInfo)
65+ public string GetConfirmCaption()
5966 {
60- return GetCaption(MSG_KEY_CAPTION_ERROR, dlgInfo);
67+ return FormatDefaultCaption(MSG_KEY_CAPTION_FORMAT_ERROR);
68+ }
69+
70+ public string FormatConfirmCaption(string captionKey)
71+ {
72+ return FormatCaption(MSG_KEY_CAPTION_FORMAT_CONFIRM, captionKey);
6173 }
6274
6375 public string GetExceptionCaption(Exception e)
6476 {
65- return GetExceptionCaption(e, null);
77+ return FormatExceptionCaption(e, null);
6678 }
6779
68- public string GetExceptionCaption(Exception e, DlgInfo dlgInfo)
80+ public string FormatExceptionCaption(Exception e, string captionKey)
6981 {
70- if (dlgInfo == null)
82+ string caption;
83+
84+ if (string.IsNullOrEmpty(captionKey))
7185 {
72- dlgInfo = defaultDlgInfo;
86+ caption = GetDefaultCaption();
7387 }
74- return string.Format(repo.Get(MSG_KEY_CAPTION_EXCEPTION), dlgInfo.Caption, e.GetType().Name);
88+ else
89+ {
90+ caption = GetCaption(captionKey);
91+ }
92+
93+ string format = GetCaption(MSG_KEY_CAPTION_FORMAT_EXCEPTION);
94+
95+ return string.Format(format, caption, e.GetType().Name);
7596 }
7697
77- protected string GetCaption(string msgCaptionKey)
98+ protected string FormatDefaultCaption(string captionFormatKey)
7899 {
79- return GetCaption(msgCaptionKey, null);
100+ return FormatCaption(captionFormatKey, null);
80101 }
81102
82- protected string GetCaption(string msgCaptionKey, DlgInfo dlgInfo)
103+ protected string FormatCaption(string captionFormatKey, string captionKey)
83104 {
84- if (dlgInfo == null)
105+ string caption;
106+
107+ if (string.IsNullOrEmpty(captionKey))
85108 {
86- dlgInfo = defaultDlgInfo;
109+ caption = GetDefaultCaption();
87110 }
88- return string.Format(repo.Get(msgCaptionKey), dlgInfo.Caption);
111+ else
112+ {
113+ caption = GetCaption(captionKey);
114+ }
115+
116+ string format = GetCaption(captionFormatKey);
117+
118+ return string.Format(format, caption);
89119 }
90120
91121 }
--- a/Core/Resource/ICaptionFormatter.cs
+++ b/Core/Resource/ICaptionFormatter.cs
@@ -1,19 +1,20 @@
1-using CleanAuLait48.Adaptor.Gateway.UI;
2-using System;
1+using System;
32
43 namespace CleanAuLait48.Core.Resource
54 {
65 public interface ICaptionFormatter
76 {
8- string GetCaption();
9- DlgInfo GetDefaultDlgInfo();
10- string GetErrorCaption();
11- string GetErrorCaption(DlgInfo dlgInfo);
12- string GetExceptionCaption(Exception e);
13- string GetExceptionCaption(Exception e, DlgInfo dlgInfo);
7+ string GetDefaultCaption();
8+ string GetCaption(string captionKey);
149 string GetInfoCaption();
15- string GetInfoCaption(DlgInfo dlgInfo);
10+ string FormatInfoCaption(string captionKey);
1611 string GetWarnCaption();
17- string GetWarnCaption(DlgInfo dlgInfo);
12+ string FormatWarnCaption(string captionKey);
13+ string GetErrorCaption();
14+ string FormatErrorCaption(string captionKey);
15+ string GetConfirmCaption();
16+ string FormatConfirmCaption(string captionKey);
17+ string GetExceptionCaption(Exception e);
18+ string FormatExceptionCaption(Exception e, string captionKey);
1819 }
1920 }
\ No newline at end of file
--- a/Core/Resource/MessageRepository.cs
+++ b/Core/Resource/MessageRepository.cs
@@ -1,12 +1,9 @@
1-using System.Collections.Generic;
2-using System.Reflection;
1+using System.Reflection;
32
43 namespace CleanAuLait48.Core.Resource
54 {
6- public class MessageRepository : IMessageRepository
5+ public class MessageRepository : AbstractMessageRepository
76 {
8- private readonly IDictionary<string, string> map = new Dictionary<string, string>();
9-
107 public MessageRepository(string nameSpace, string path, Assembly asm)
118 {
129 ReadMessageResource(nameSpace, path, asm);
@@ -29,17 +26,5 @@ namespace CleanAuLait48.Core.Resource
2926 map.Add(data[0].Trim(), data[1].Trim());
3027 }
3128 }
32-
33- public string Get(string key)
34- {
35- return map[key];
36- }
37-
38- public string Get(string key, params string[] args)
39- {
40- string msg = map[key];
41-
42- return string.Format(msg, args);
43- }
4429 }
4530 }
--- a/Core/Helper/DateTimeHelper.cs
+++ b/Core/Time/DateTimeHelper.cs
@@ -1,6 +1,6 @@
11 using System;
22
3-namespace CleanAuLait48.Core.Helper
3+namespace CleanAuLait48.Core.Time
44 {
55 public static class DateTimeHelper
66 {
@@ -10,6 +10,13 @@ namespace CleanAuLait48.Core.Helper
1010
1111 public static DateTime JstNow => TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, TZ_JST);
1212
13- public static long ToUnixTime(DateTime time) => (long)((time - UNIX_EPOCH).TotalSeconds);
13+#if NET7_0
14+ public static long ToUnixTime(DateTime time) => (long)((time - UNIX_EPOCH).TotalSeconds) * 1000000 + time.Microsecond;
15+#else
16+ public static long ToUnixTime(DateTime time)
17+ {
18+ return (long) ((time - UNIX_EPOCH).TotalSeconds) * 1000000 + long.Parse(time.ToString("ffffff"));
19+ }
20+#endif
1421 }
1522 }
--- a/UseCase/Request/UIUseCaseRequest.cs
+++ /dev/null
@@ -1,18 +0,0 @@
1-using CleanAuLait48.Adaptor.Gateway.UI;
2-
3-namespace CleanAuLait48.UseCase.Request
4-{
5- public abstract class UIUseCaseRequest : UseCaseRequest
6- {
7- public DlgInfo UIInfo { get; set; }
8-
9- public UIUseCaseRequest(string caption) : this(new DlgInfo(caption))
10- {
11- }
12-
13- public UIUseCaseRequest(DlgInfo uiInfo)
14- {
15- this.UIInfo = uiInfo;
16- }
17- }
18-}