• R/O
  • HTTP
  • SSH
  • HTTPS

提交

標籤
無標籤

Frequently used words (click to add to your profile)

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

Commit MetaInfo

修訂cfa22461ae837e893170d945e08595c56e7c4bf7 (tree)
時間2022-05-21 18:58:48
作者yoshy <yoshy.org.bitbucket@gz.j...>
Commiteryoshy

Log Message

[MOD] キャプションクラスをアプリ側で拡張可能なようにリファクタ

Change Summary

差異

--- a/Core/Resource/CaptionFormatter.cs
+++ b/Core/Resource/CaptionFormatter.cs
@@ -11,8 +11,8 @@ namespace CleanAuLait48.Core.Resource
1111 public const string MSG_KEY_CAPTION_ERROR = "Caption.Error";
1212 public const string MSG_KEY_CAPTION_EXCEPTION = "Caption.Exception";
1313
14- private readonly IMessageRepository repo;
15- private readonly DlgInfo defaultDlgInfo;
14+ protected readonly IMessageRepository repo;
15+ protected readonly DlgInfo defaultDlgInfo;
1616
1717 public CaptionFormatter(IMessageRepository repo)
1818 {
@@ -32,44 +32,32 @@ namespace CleanAuLait48.Core.Resource
3232
3333 public string GetInfoCaption()
3434 {
35- return GetInfoCaption(null);
35+ return GetCaption(MSG_KEY_CAPTION_INFO);
3636 }
3737
3838 public string GetInfoCaption(DlgInfo dlgInfo)
3939 {
40- if (dlgInfo == null)
41- {
42- dlgInfo = defaultDlgInfo;
43- }
44- return string.Format(repo.Get(MSG_KEY_CAPTION_INFO), dlgInfo.Caption);
40+ return GetCaption(MSG_KEY_CAPTION_INFO, dlgInfo);
4541 }
4642
4743 public string GetWarnCaption()
4844 {
49- return GetWarnCaption(null);
45+ return GetCaption(MSG_KEY_CAPTION_WARN);
5046 }
5147
5248 public string GetWarnCaption(DlgInfo dlgInfo)
5349 {
54- if (dlgInfo == null)
55- {
56- dlgInfo = defaultDlgInfo;
57- }
58- return string.Format(repo.Get(MSG_KEY_CAPTION_WARN), dlgInfo.Caption);
50+ return GetCaption(MSG_KEY_CAPTION_WARN, dlgInfo);
5951 }
6052
6153 public string GetErrorCaption()
6254 {
63- return GetErrorCaption(null);
55+ return GetCaption(MSG_KEY_CAPTION_ERROR);
6456 }
6557
6658 public string GetErrorCaption(DlgInfo dlgInfo)
6759 {
68- if (dlgInfo == null)
69- {
70- dlgInfo = defaultDlgInfo;
71- }
72- return string.Format(repo.Get(MSG_KEY_CAPTION_ERROR), dlgInfo.Caption);
60+ return GetCaption(MSG_KEY_CAPTION_ERROR, dlgInfo);
7361 }
7462
7563 public string GetExceptionCaption(Exception e)
@@ -85,5 +73,20 @@ namespace CleanAuLait48.Core.Resource
8573 }
8674 return string.Format(repo.Get(MSG_KEY_CAPTION_EXCEPTION), dlgInfo.Caption, e.GetType().Name);
8775 }
76+
77+ protected string GetCaption(string msgCaptionKey)
78+ {
79+ return GetCaption(msgCaptionKey, null);
80+ }
81+
82+ protected string GetCaption(string msgCaptionKey, DlgInfo dlgInfo)
83+ {
84+ if (dlgInfo == null)
85+ {
86+ dlgInfo = defaultDlgInfo;
87+ }
88+ return string.Format(repo.Get(msgCaptionKey), dlgInfo.Caption);
89+ }
90+
8891 }
8992 }