|
1 | 1 | using Common.BasicHelper.Core.Shell; |
| 2 | +using Common.BasicHelper.Graphics.Screen; |
2 | 3 | using Common.BasicHelper.Utils.Extensions; |
3 | 4 | using System.Web; |
4 | 5 |
|
|
20 | 21 |
|
21 | 22 | app.UseHttpsRedirection(); |
22 | 23 |
|
| 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 | + |
23 | 39 | app.MapGet("/Utils/Extensions/StringHelper/ExecuteAsCommand/{cmd}.{args?}", |
24 | 40 | (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) |
27 | 42 | ) |
28 | 43 | ) |
29 | 44 | .WithName("ExecuteAsCommand") |
30 | 45 | .WithOpenApi(); |
31 | 46 |
|
32 | 47 | app.MapGet("/Utils/Extensions/StringHelper/ExecuteAsCommandAsync/{cmd}.{args?}", |
33 | 48 | 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) |
36 | 50 | ) |
37 | 51 | ) |
38 | 52 | .WithName("ExecuteAsCommandAsync") |
|
0 commit comments