Skip to content

Commit 8b71d53

Browse files
committed
💾 Feat(Samples): Added new sample and redirect to swagger defaultly.
1 parent 9266d3c commit 8b71d53

1 file changed

Lines changed: 18 additions & 4 deletions

File tree

‎Common.BasicHelper.Samples/Program.cs‎

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using Common.BasicHelper.Core.Shell;
2+
using Common.BasicHelper.Graphics.Screen;
23
using Common.BasicHelper.Utils.Extensions;
34
using System.Web;
45

@@ -20,19 +21,32 @@
2021

2122
app.UseHttpsRedirection();
2223

24+
static bool parameterNullCheck(string? param, string? name = null)
25+
{
26+
return param == "," || param == $"{{{name}}}" || param.IsNullOrWhiteSpace();
27+
}
28+
29+
app.MapGet("/", () => Results.Redirect("/swagger/index.html"));
30+
31+
app.MapGet("/Graphics/Screen/Resolution/Parse/{resolution}.{descr?}",
32+
(string resolution, string? descr) => Resolution.Parse(
33+
resolution, parameterNullCheck(descr, nameof(descr)) ? null : descr
34+
)
35+
)
36+
.WithName("ParseSolution")
37+
.WithOpenApi();
38+
2339
app.MapGet("/Utils/Extensions/StringHelper/ExecuteAsCommand/{cmd}.{args?}",
2440
(string cmd, string? args) => cmd.ExecuteAsCommand(
25-
args == "," || args == "{args}" || args.IsNullOrWhiteSpace()
26-
? null : HttpUtility.UrlDecode(args)
41+
parameterNullCheck(args, nameof(args)) ? null : HttpUtility.UrlDecode(args)
2742
)
2843
)
2944
.WithName("ExecuteAsCommand")
3045
.WithOpenApi();
3146

3247
app.MapGet("/Utils/Extensions/StringHelper/ExecuteAsCommandAsync/{cmd}.{args?}",
3348
async (string cmd, string? args) => await cmd.ExecuteAsCommandAsync(
34-
args == "," || args == "{args}" || args.IsNullOrWhiteSpace()
35-
? null : HttpUtility.UrlDecode(args)
49+
parameterNullCheck(args, nameof(args)) ? null : HttpUtility.UrlDecode(args)
3650
)
3751
)
3852
.WithName("ExecuteAsCommandAsync")

0 commit comments

Comments
 (0)