Skip to content

Commit 907276b

Browse files
committed
[r] meta info, file-scoped namespace
[add] .NET 6 target framework
1 parent 6a8d8b5 commit 907276b

File tree

9 files changed

+287
-282
lines changed

9 files changed

+287
-282
lines changed

.vscode/settings.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"cSpell.words": [
3+
"cref"
4+
]
5+
}

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
[![Build Package](https://github.com/SimplifyNet/Simplify.Web.MessageBox/actions/workflows/build.yml/badge.svg)](https://github.com/SimplifyNet/Simplify.Web.MessageBox/actions/workflows/build.yml)
66
[![Libraries.io dependency status for latest release](https://img.shields.io/librariesio/release/nuget/Simplify.Web.MessageBox)](https://libraries.io/nuget/Simplify.Web.MessageBox)
77
[![CodeFactor Grade](https://img.shields.io/codefactor/grade/github/SimplifyNet/Simplify.Web.MessageBox)](https://www.codefactor.io/repository/github/simplifynet/simplify.web.MessageBox)
8-
![Platform](https://img.shields.io/badge/platform-NET%205.0%20%7C%20.NET%20Standard%202.0%20%7C%20.NET%204.6.2-lightgrey)
8+
![Platform](https://img.shields.io/badge/platform-.NET%206.0%20%7C%20.NET%205.0%20%7C%20.NET%20Standard%202.0%20%7C%20.NET%204.6.2-lightgrey)
99
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen)](http://makeapullrequest.com)
1010

1111
`Simplify.Web.MessageBox` is a package which provides non-interactive server side message box for [Simplify.Web](https://github.com/SimplifyNet/Simplify.Web) web-framework.

src/Simplify.Web.MessageBox/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## [1.4.5] - 2022-05-18
4+
5+
### Dependencies
6+
7+
- Simplify.Web bump to 4.6 (PR#14)
8+
39
## [1.4.4] - 2021-11-24
410

511
### Dependencies
Lines changed: 44 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,53 @@
11
using Simplify.Web.Modules.Data;
22

3-
namespace Simplify.Web.MessageBox
3+
namespace Simplify.Web.MessageBox;
4+
5+
/// <summary>
6+
/// The HTML message box
7+
/// Usable template files:
8+
/// "Simplify.Web/MessageBox/InfoMessageBox.tpl"
9+
/// "Simplify.Web/MessageBox/ErrorMessageBox.tpl"
10+
/// "Simplify.Web/MessageBox/OkMessageBox.tpl"
11+
/// "Simplify.Web/MessageBox/InlineInfoMessageBox.tpl"
12+
/// "Simplify.Web/MessageBox/InlineErrorMessageBox.tpl"
13+
/// "Simplify.Web/MessageBox/InlineOkMessageBox.tpl"
14+
/// Usable <see cref="StringTable"/> items:
15+
/// "FormTitleMessageBox"
16+
/// Template variables:
17+
/// "Message"
18+
/// "Title"
19+
/// </summary>
20+
public interface IMessageBoxHandler
421
{
522
/// <summary>
6-
/// The HTML message box
7-
/// Usable template files:
8-
/// "Simplify.Web/MessageBox/InfoMessageBox.tpl"
9-
/// "Simplify.Web/MessageBox/ErrorMessageBox.tpl"
10-
/// "Simplify.Web/MessageBox/OkMessageBox.tpl"
11-
/// "Simplify.Web/MessageBox/InlineInfoMessageBox.tpl"
12-
/// "Simplify.Web/MessageBox/InlineErrorMessageBox.tpl"
13-
/// "Simplify.Web/MessageBox/InlineOkMessageBox.tpl"
14-
/// Usable <see cref="StringTable"/> items:
15-
/// "FormTitleMessageBox"
16-
/// Template variables:
17-
/// "Message"
18-
/// "Title"
23+
/// Generate message box HTML and set to data collector
1924
/// </summary>
20-
public interface IMessageBoxHandler
21-
{
22-
/// <summary>
23-
/// Generate message box HTML and set to data collector
24-
/// </summary>
25-
/// <param name="text">Text of a message box</param>
26-
/// <param name="status">Status of a message box</param>
27-
/// <param name="title">Title of a message box</param>
28-
void Show(string text, MessageBoxStatus status = MessageBoxStatus.Error, string? title = null);
25+
/// <param name="text">Text of a message box</param>
26+
/// <param name="status">Status of a message box</param>
27+
/// <param name="title">Title of a message box</param>
28+
void Show(string text, MessageBoxStatus status = MessageBoxStatus.Error, string? title = null);
2929

30-
/// <summary>
31-
///Generate message box HTML and set to data collector
32-
/// </summary>
33-
/// <param name="stringTableItemName">Show message from string table item</param>
34-
/// <param name="status">Status of a message box</param>
35-
/// <param name="title">Title of a message box</param>
36-
void ShowSt(string stringTableItemName, MessageBoxStatus status = MessageBoxStatus.Error, string? title = null);
30+
/// <summary>
31+
///Generate message box HTML and set to data collector
32+
/// </summary>
33+
/// <param name="stringTableItemName">Show message from string table item</param>
34+
/// <param name="status">Status of a message box</param>
35+
/// <param name="title">Title of a message box</param>
36+
void ShowSt(string stringTableItemName, MessageBoxStatus status = MessageBoxStatus.Error, string? title = null);
3737

38-
/// <summary>
39-
/// Get inline message box HTML
40-
/// </summary>
41-
/// <param name="text">Text of a message box</param>
42-
/// <param name="status">Status of a message box</param>
43-
/// <returns>Message box html</returns>
44-
string GetInline(string text, MessageBoxStatus status = MessageBoxStatus.Error);
38+
/// <summary>
39+
/// Get inline message box HTML
40+
/// </summary>
41+
/// <param name="text">Text of a message box</param>
42+
/// <param name="status">Status of a message box</param>
43+
/// <returns>Message box html</returns>
44+
string GetInline(string text, MessageBoxStatus status = MessageBoxStatus.Error);
4545

46-
/// <summary>
47-
/// Get inline message box HTML
48-
/// </summary>
49-
/// <param name="stringTableItemName">Show message from string table item</param>
50-
/// <param name="status">Status of a message box</param>
51-
/// <returns>Message box html</returns>
52-
string GetInlineSt(string stringTableItemName, MessageBoxStatus status = MessageBoxStatus.Error);
53-
}
46+
/// <summary>
47+
/// Get inline message box HTML
48+
/// </summary>
49+
/// <param name="stringTableItemName">Show message from string table item</param>
50+
/// <param name="status">Status of a message box</param>
51+
/// <returns>Message box html</returns>
52+
string GetInlineSt(string stringTableItemName, MessageBoxStatus status = MessageBoxStatus.Error);
5453
}
Lines changed: 108 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -1,135 +1,134 @@
11
using System;
22
using Simplify.Web.Modules.Data;
33

4-
namespace Simplify.Web.MessageBox
4+
namespace Simplify.Web.MessageBox;
5+
6+
/// <summary>
7+
/// The HTML message box
8+
/// Usable template files:
9+
/// "Simplify.Web/MessageBox/InfoMessageBox.tpl"
10+
/// "Simplify.Web/MessageBox/ErrorMessageBox.tpl"
11+
/// "Simplify.Web/MessageBox/OkMessageBox.tpl"
12+
/// "Simplify.Web/MessageBox/InlineInfoMessageBox.tpl"
13+
/// "Simplify.Web/MessageBox/InlineErrorMessageBox.tpl"
14+
/// "Simplify.Web/MessageBox/InlineOkMessageBox.tpl"
15+
/// Usable <see cref="StringTable"/> items:
16+
/// "FormTitleMessageBox"
17+
/// Template variables:
18+
/// "Message"
19+
/// "Title"
20+
/// </summary>
21+
public sealed class MessageBoxHandler : IMessageBoxHandler
522
{
623
/// <summary>
7-
/// The HTML message box
8-
/// Usable template files:
9-
/// "Simplify.Web/MessageBox/InfoMessageBox.tpl"
10-
/// "Simplify.Web/MessageBox/ErrorMessageBox.tpl"
11-
/// "Simplify.Web/MessageBox/OkMessageBox.tpl"
12-
/// "Simplify.Web/MessageBox/InlineInfoMessageBox.tpl"
13-
/// "Simplify.Web/MessageBox/InlineErrorMessageBox.tpl"
14-
/// "Simplify.Web/MessageBox/InlineOkMessageBox.tpl"
15-
/// Usable <see cref="StringTable"/> items:
16-
/// "FormTitleMessageBox"
17-
/// Template variables:
18-
/// "Message"
19-
/// "Title"
24+
/// The message box templates path
2025
/// </summary>
21-
public sealed class MessageBoxHandler : IMessageBoxHandler
22-
{
23-
/// <summary>
24-
/// The message box templates path
25-
/// </summary>
26-
public const string MessageBoxTemplatesPath = "App_Packages/Simplify.Web.MessageBox/";
27-
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-
}
26+
public const string MessageBoxTemplatesPath = "App_Packages/Simplify.Web.MessageBox/";
4427

45-
/// <summary>
46-
/// Generate message box HTML and set to data collector
47-
/// </summary>
48-
/// <param name="text">Text of a message box</param>
49-
/// <param name="status">Status of a message box</param>
50-
/// <param name="title">Title of a message box</param>
51-
public void Show(string? text, MessageBoxStatus status = MessageBoxStatus.Error, string? title = null)
52-
{
53-
if (string.IsNullOrEmpty(text))
54-
throw new ArgumentNullException(nameof(text));
28+
private readonly ITemplateFactory _templateFactory;
29+
private readonly IStringTable _stringTable;
30+
private readonly IDataCollector _dataCollector;
5531

56-
var templateFile = MessageBoxTemplatesPath;
57-
58-
switch (status)
59-
{
60-
case MessageBoxStatus.Information:
61-
templateFile += "InfoMessageBox.tpl";
62-
break;
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+
}
6344

64-
case MessageBoxStatus.Error:
65-
templateFile += "ErrorMessageBox.tpl";
66-
break;
45+
/// <summary>
46+
/// Generate message box HTML and set to data collector
47+
/// </summary>
48+
/// <param name="text">Text of a message box</param>
49+
/// <param name="status">Status of a message box</param>
50+
/// <param name="title">Title of a message box</param>
51+
public void Show(string? text, MessageBoxStatus status = MessageBoxStatus.Error, string? title = null)
52+
{
53+
if (string.IsNullOrEmpty(text))
54+
throw new ArgumentNullException(nameof(text));
6755

68-
case MessageBoxStatus.Ok:
69-
templateFile += "OkMessageBox.tpl";
70-
break;
71-
}
56+
var templateFile = MessageBoxTemplatesPath;
7257

73-
var tpl = _templateFactory.Load(templateFile);
58+
switch (status)
59+
{
60+
case MessageBoxStatus.Information:
61+
templateFile += "InfoMessageBox.tpl";
62+
break;
7463

75-
tpl.Set("Message", text);
76-
tpl.Set("Title", string.IsNullOrEmpty(title) ? _stringTable.GetItem("FormTitleMessageBox") : title);
64+
case MessageBoxStatus.Error:
65+
templateFile += "ErrorMessageBox.tpl";
66+
break;
7767

78-
_dataCollector.Add(tpl.Get());
79-
_dataCollector.AddTitle(string.IsNullOrEmpty(title) ? _stringTable.GetItem("FormTitleMessageBox") : title);
68+
case MessageBoxStatus.Ok:
69+
templateFile += "OkMessageBox.tpl";
70+
break;
8071
}
8172

82-
/// <summary>
83-
///Generate message box HTML and set to data collector
84-
/// </summary>
85-
/// <param name="stringTableItemName">Show message from string table item</param>
86-
/// <param name="status">Status of a message box</param>
87-
/// <param name="title">Title of a message box</param>
88-
public void ShowSt(string stringTableItemName, MessageBoxStatus status = MessageBoxStatus.Error, string? title = null) =>
89-
Show(_stringTable.GetItem(stringTableItemName), status, title);
90-
91-
/// <summary>
92-
/// Get inline message box HTML
93-
/// </summary>
94-
/// <param name="text">Text of a message box</param>
95-
/// <param name="status">Status of a message box</param>
96-
/// <returns>Message box html</returns>
97-
public string GetInline(string? text, MessageBoxStatus status = MessageBoxStatus.Error)
98-
{
99-
if (string.IsNullOrEmpty(text))
100-
throw new ArgumentNullException(nameof(text));
73+
var tpl = _templateFactory.Load(templateFile);
10174

102-
var templateFile = MessageBoxTemplatesPath;
75+
tpl.Set("Message", text);
76+
tpl.Set("Title", string.IsNullOrEmpty(title) ? _stringTable.GetItem("FormTitleMessageBox") : title);
10377

104-
switch (status)
105-
{
106-
case MessageBoxStatus.Information:
107-
templateFile += "InlineInfoMessageBox.tpl";
108-
break;
78+
_dataCollector.Add(tpl.Get());
79+
_dataCollector.AddTitle(string.IsNullOrEmpty(title) ? _stringTable.GetItem("FormTitleMessageBox") : title);
80+
}
10981

110-
case MessageBoxStatus.Error:
111-
templateFile += "InlineErrorMessageBox.tpl";
112-
break;
82+
/// <summary>
83+
///Generate message box HTML and set to data collector
84+
/// </summary>
85+
/// <param name="stringTableItemName">Show message from string table item</param>
86+
/// <param name="status">Status of a message box</param>
87+
/// <param name="title">Title of a message box</param>
88+
public void ShowSt(string stringTableItemName, MessageBoxStatus status = MessageBoxStatus.Error, string? title = null) =>
89+
Show(_stringTable.GetItem(stringTableItemName), status, title);
11390

114-
case MessageBoxStatus.Ok:
115-
templateFile += "InlineOkMessageBox.tpl";
116-
break;
117-
}
91+
/// <summary>
92+
/// Get inline message box HTML
93+
/// </summary>
94+
/// <param name="text">Text of a message box</param>
95+
/// <param name="status">Status of a message box</param>
96+
/// <returns>Message box html</returns>
97+
public string GetInline(string? text, MessageBoxStatus status = MessageBoxStatus.Error)
98+
{
99+
if (string.IsNullOrEmpty(text))
100+
throw new ArgumentNullException(nameof(text));
118101

119-
var tpl = _templateFactory.Load(templateFile);
102+
var templateFile = MessageBoxTemplatesPath;
120103

121-
tpl.Set("Message", text);
104+
switch (status)
105+
{
106+
case MessageBoxStatus.Information:
107+
templateFile += "InlineInfoMessageBox.tpl";
108+
break;
122109

123-
return tpl.Get();
110+
case MessageBoxStatus.Error:
111+
templateFile += "InlineErrorMessageBox.tpl";
112+
break;
113+
114+
case MessageBoxStatus.Ok:
115+
templateFile += "InlineOkMessageBox.tpl";
116+
break;
124117
}
125118

126-
/// <summary>
127-
/// Get inline message box HTML
128-
/// </summary>
129-
/// <param name="stringTableItemName">Show message from string table item</param>
130-
/// <param name="status">Status of a message box</param>
131-
/// <returns>Message box html</returns>
132-
public string GetInlineSt(string stringTableItemName, MessageBoxStatus status = MessageBoxStatus.Error) =>
133-
GetInline(_stringTable.GetItem(stringTableItemName), status);
119+
var tpl = _templateFactory.Load(templateFile);
120+
121+
tpl.Set("Message", text);
122+
123+
return tpl.Get();
134124
}
125+
126+
/// <summary>
127+
/// Get inline message box HTML
128+
/// </summary>
129+
/// <param name="stringTableItemName">Show message from string table item</param>
130+
/// <param name="status">Status of a message box</param>
131+
/// <returns>Message box html</returns>
132+
public string GetInlineSt(string stringTableItemName, MessageBoxStatus status = MessageBoxStatus.Error) =>
133+
GetInline(_stringTable.GetItem(stringTableItemName), status);
135134
}

0 commit comments

Comments
 (0)