• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

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

Commit MetaInfo

Revisionc3a256ccb4a9a5823695d2237d31680b12931560 (tree)
Time2022-11-29 23:54:33
Authoryoshy <yoshy.org.bitbucket@gz.j...>
Commiteryoshy

Log Message

[MOD] キャプション書式化機能でキャプションの取得と書式化を行う機能の区別を明確にした

Change Summary

Incremental Difference

--- a/Core/Resource/CaptionFormatter.cs
+++ b/Core/Resource/CaptionFormatter.cs
@@ -3,10 +3,14 @@
33 public class CaptionFormatter : ICaptionFormatter
44 {
55 public const string MSG_KEY_CAPTION = "Caption";
6- public const string MSG_KEY_CAPTION_INFO = "Caption.Info";
7- public const string MSG_KEY_CAPTION_WARN = "Caption.Warn";
8- public const string MSG_KEY_CAPTION_ERROR = "Caption.Error";
9- public const string MSG_KEY_CAPTION_EXCEPTION = "Caption.Exception";
6+
7+ public const string MSG_KEY_PREFIX_CAPTION_FORMAT = "Caption.Format.";
8+
9+ public const string MSG_KEY_CAPTION_FORMAT_INFO = MSG_KEY_PREFIX_CAPTION_FORMAT + "Info";
10+ public const string MSG_KEY_CAPTION_FORMAT_WARN = MSG_KEY_PREFIX_CAPTION_FORMAT + "Warn";
11+ public const string MSG_KEY_CAPTION_FORMAT_ERROR = MSG_KEY_PREFIX_CAPTION_FORMAT + "Error";
12+ public const string MSG_KEY_CAPTION_FORMAT_CONFIRM = MSG_KEY_PREFIX_CAPTION_FORMAT + "Confirm";
13+ public const string MSG_KEY_CAPTION_FORMAT_EXCEPTION = MSG_KEY_PREFIX_CAPTION_FORMAT + "Exception";
1014
1115 protected readonly IMessageRepository repo;
1216
@@ -15,67 +19,100 @@
1519 this.repo = repo;
1620 }
1721
18- public string GetCaption()
22+ public string GetDefaultCaption()
23+ {
24+ return GetCaption(MSG_KEY_CAPTION);
25+ }
26+
27+ public string GetCaption(string captionKey)
1928 {
20- return repo.Get(MSG_KEY_CAPTION);
29+ return this.repo.Get(captionKey);
2130 }
2231
2332 public string GetInfoCaption()
2433 {
25- return GetCaption(MSG_KEY_CAPTION_INFO);
34+ return FormatDefaultCaption(MSG_KEY_CAPTION_FORMAT_INFO);
2635 }
2736
28- public string GetInfoCaption(string caption)
37+ public string FormatInfoCaption(string captionKey)
2938 {
30- return GetCaption(MSG_KEY_CAPTION_INFO, caption);
39+ return FormatCaption(MSG_KEY_CAPTION_FORMAT_INFO, captionKey);
3140 }
3241
3342 public string GetWarnCaption()
3443 {
35- return GetCaption(MSG_KEY_CAPTION_WARN);
44+ return FormatDefaultCaption(MSG_KEY_CAPTION_FORMAT_WARN);
3645 }
3746
38- public string GetWarnCaption(string caption)
47+ public string FormatWarnCaption(string captionKey)
3948 {
40- return GetCaption(MSG_KEY_CAPTION_WARN, caption);
49+ return FormatCaption(MSG_KEY_CAPTION_FORMAT_WARN, captionKey);
4150 }
4251
4352 public string GetErrorCaption()
4453 {
45- return GetCaption(MSG_KEY_CAPTION_ERROR);
54+ return FormatDefaultCaption(MSG_KEY_CAPTION_FORMAT_ERROR);
55+ }
56+
57+ public string FormatErrorCaption(string captionKey)
58+ {
59+ return FormatCaption(MSG_KEY_CAPTION_FORMAT_ERROR, captionKey);
60+ }
61+
62+ public string GetConfirmCaption()
63+ {
64+ return FormatDefaultCaption(MSG_KEY_CAPTION_FORMAT_ERROR);
4665 }
4766
48- public string GetErrorCaption(string caption)
67+ public string FormatConfirmCaption(string captionKey)
4968 {
50- return GetCaption(MSG_KEY_CAPTION_ERROR, caption);
69+ return FormatCaption(MSG_KEY_CAPTION_FORMAT_CONFIRM, captionKey);
5170 }
5271
5372 public string GetExceptionCaption(Exception e)
5473 {
55- return GetExceptionCaption(e, null);
74+ return FormatExceptionCaption(e, null);
5675 }
5776
58- public string GetExceptionCaption(Exception e, string caption)
77+ public string FormatExceptionCaption(Exception e, string captionKey)
5978 {
60- if (string.IsNullOrEmpty(caption))
79+ string caption;
80+
81+ if (string.IsNullOrEmpty(captionKey))
82+ {
83+ caption = GetDefaultCaption();
84+ }
85+ else
6186 {
62- caption = GetCaption();
87+ caption = GetCaption(captionKey);
6388 }
64- return string.Format(repo.Get(MSG_KEY_CAPTION_EXCEPTION), caption, e.GetType().Name);
89+
90+ string format = GetCaption(MSG_KEY_CAPTION_FORMAT_EXCEPTION);
91+
92+ return string.Format(format, caption, e.GetType().Name);
6593 }
6694
67- protected string GetCaption(string msgCaptionKey)
95+ protected string FormatDefaultCaption(string captionFormatKey)
6896 {
69- return GetCaption(msgCaptionKey, null);
97+ return FormatCaption(captionFormatKey, null);
7098 }
7199
72- protected string GetCaption(string msgCaptionKey, string caption)
100+ protected string FormatCaption(string captionFormatKey, string captionKey)
73101 {
74- if (string.IsNullOrEmpty(caption))
102+ string caption;
103+
104+ if (string.IsNullOrEmpty(captionKey))
105+ {
106+ caption = GetDefaultCaption();
107+ }
108+ else
75109 {
76- caption = GetCaption();
110+ caption = GetCaption(captionKey);
77111 }
78- return string.Format(repo.Get(msgCaptionKey), caption);
112+
113+ string format = GetCaption(captionFormatKey);
114+
115+ return string.Format(format, caption);
79116 }
80117
81118 }
--- a/Core/Resource/ICaptionFormatter.cs
+++ b/Core/Resource/ICaptionFormatter.cs
@@ -2,14 +2,17 @@
22 {
33 public interface ICaptionFormatter
44 {
5- string GetCaption();
6- string GetErrorCaption();
7- string GetErrorCaption(string caption);
8- string GetExceptionCaption(Exception e);
9- string GetExceptionCaption(Exception e, string caption);
5+ string GetDefaultCaption();
6+ string GetCaption(string captionKey);
107 string GetInfoCaption();
11- string GetInfoCaption(string caption);
8+ string FormatInfoCaption(string captionKey);
129 string GetWarnCaption();
13- string GetWarnCaption(string caption);
10+ string FormatWarnCaption(string captionKey);
11+ string GetErrorCaption();
12+ string FormatErrorCaption(string captionKey);
13+ string GetConfirmCaption();
14+ string FormatConfirmCaption(string captionKey);
15+ string GetExceptionCaption(Exception e);
16+ string FormatExceptionCaption(Exception e, string captionKey);
1417 }
1518 }
\ No newline at end of file