44namespace Simplify . Web . MessageBox ;
55
66/// <summary>
7- /// The HTML message box
7+ /// Provides the HTML message box.
88/// Usable template files:
99/// "Simplify.Web/MessageBox/InfoMessageBox.tpl"
1010/// "Simplify.Web/MessageBox/ErrorMessageBox.tpl"
1111/// "Simplify.Web/MessageBox/OkMessageBox.tpl"
1212/// "Simplify.Web/MessageBox/InlineInfoMessageBox.tpl"
1313/// "Simplify.Web/MessageBox/InlineErrorMessageBox.tpl"
1414/// "Simplify.Web/MessageBox/InlineOkMessageBox.tpl"
15- /// Usable <see cref="StringTable"/> items:
15+ /// Usable <see cref="StringTable" /> items:
1616/// "FormTitleMessageBox"
1717/// Template variables:
1818/// "Message"
1919/// "Title"
2020/// </summary>
21- public sealed class MessageBoxHandler : IMessageBoxHandler
21+ /// <seealso cref="IMessageBoxHandler" />
22+ /// <remarks>
23+ /// Initializes a new instance of the <see cref="MessageBoxHandler" /> class.
24+ /// </remarks>
25+ /// <param name="templateFactory">The template factory.</param>
26+ /// <param name="stringTable">The string table.</param>
27+ /// <param name="dataCollector">The data collector.</param>
28+ public sealed class MessageBoxHandler ( ITemplateFactory templateFactory , IStringTable stringTable , IDataCollector dataCollector ) : IMessageBoxHandler
2229{
2330 /// <summary>
2431 /// The message box templates path
2532 /// </summary>
2633 public const string MessageBoxTemplatesPath = "App_Packages/Simplify.Web.MessageBox/" ;
2734
28- private readonly ITemplateFactory _templateFactory ;
29- private readonly IStringTable _stringTable ;
30- private readonly IDataCollector _dataCollector ;
31-
32- /// <summary>
33- /// Initializes a new instance of the <see cref="MessageBoxHandler"/> class.
34- /// </summary>
35- /// <param name="templateFactory">The template factory.</param>
36- /// <param name="stringTable">The string table.</param>
37- /// <param name="dataCollector">The data collector.</param>
38- public MessageBoxHandler ( ITemplateFactory templateFactory , IStringTable stringTable , IDataCollector dataCollector )
39- {
40- _templateFactory = templateFactory ;
41- _stringTable = stringTable ;
42- _dataCollector = dataCollector ;
43- }
44-
4535 /// <summary>
4636 /// Generate message box HTML and set to data collector
4737 /// </summary>
@@ -68,15 +58,18 @@ public void Show(string? text, MessageBoxStatus status = MessageBoxStatus.Error,
6858 case MessageBoxStatus . Ok :
6959 templateFile += "OkMessageBox.tpl" ;
7060 break ;
61+
62+ default :
63+ throw new ArgumentOutOfRangeException ( nameof ( status ) , status , null ) ;
7164 }
7265
73- var tpl = _templateFactory . Load ( templateFile ) ;
66+ var tpl = templateFactory . Load ( templateFile ) ;
7467
7568 tpl . Set ( "Message" , text ) ;
76- tpl . Set ( "Title" , string . IsNullOrEmpty ( title ) ? _stringTable . GetItem ( "FormTitleMessageBox" ) : title ) ;
69+ tpl . Set ( "Title" , string . IsNullOrEmpty ( title ) ? stringTable . GetItem ( "FormTitleMessageBox" ) : title ) ;
7770
78- _dataCollector . Add ( tpl . Get ( ) ) ;
79- _dataCollector . AddTitle ( string . IsNullOrEmpty ( title ) ? _stringTable . GetItem ( "FormTitleMessageBox" ) : title ) ;
71+ dataCollector . Add ( tpl . Get ( ) ) ;
72+ dataCollector . AddTitle ( string . IsNullOrEmpty ( title ) ? stringTable . GetItem ( "FormTitleMessageBox" ) : title ) ;
8073 }
8174
8275 /// <summary>
@@ -86,7 +79,7 @@ public void Show(string? text, MessageBoxStatus status = MessageBoxStatus.Error,
8679 /// <param name="status">Status of a message box</param>
8780 /// <param name="title">Title of a message box</param>
8881 public void ShowSt ( string stringTableItemName , MessageBoxStatus status = MessageBoxStatus . Error , string ? title = null ) =>
89- Show ( _stringTable . GetItem ( stringTableItemName ) , status , title ) ;
82+ Show ( stringTable . GetItem ( stringTableItemName ) , status , title ) ;
9083
9184 /// <summary>
9285 /// Get inline message box HTML
@@ -114,9 +107,12 @@ public string GetInline(string? text, MessageBoxStatus status = MessageBoxStatus
114107 case MessageBoxStatus . Ok :
115108 templateFile += "InlineOkMessageBox.tpl" ;
116109 break ;
110+
111+ default :
112+ throw new ArgumentOutOfRangeException ( nameof ( status ) , status , null ) ;
117113 }
118114
119- var tpl = _templateFactory . Load ( templateFile ) ;
115+ var tpl = templateFactory . Load ( templateFile ) ;
120116
121117 tpl . Set ( "Message" , text ) ;
122118
@@ -130,5 +126,5 @@ public string GetInline(string? text, MessageBoxStatus status = MessageBoxStatus
130126 /// <param name="status">Status of a message box</param>
131127 /// <returns>Message box html</returns>
132128 public string GetInlineSt ( string stringTableItemName , MessageBoxStatus status = MessageBoxStatus . Error ) =>
133- GetInline ( _stringTable . GetItem ( stringTableItemName ) , status ) ;
129+ GetInline ( stringTable . GetItem ( stringTableItemName ) , status ) ;
134130}
0 commit comments