Skip to content

Commit ec6acb5

Browse files
committed
Fixed warnings
1 parent 40bf539 commit ec6acb5

File tree

3 files changed

+19
-10
lines changed

3 files changed

+19
-10
lines changed

src/ImageSharp.Web/Commands/PresetRequestParser.cs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,20 @@
1111
namespace SixLabors.ImageSharp.Web.Commands
1212
{
1313
/// <summary>
14-
/// Parses ImageSharp.Web image processing requests to ImageSharp.Web commands based on statically defined presets.
15-
/// The advantages of this are:
16-
/// 1. Image processing for certain scenarios can be adjusted in a single place, by adjusting the preset definition.
17-
/// 2. Security. Only known presets are applied. Limits DOS opportunities.
14+
/// Parses preset name from the request querystring and returns the commands configured for that preset.
1815
/// </summary>
1916
public class PresetRequestParser : IRequestParser
2017
{
2118
private readonly IDictionary<string, IDictionary<string, string>> presets;
2219

23-
public PresetRequestParser(IOptions<PresetRequestParserOptions> options) =>
24-
this.presets = ParsePresets(options.Value.Presets);
20+
/// <summary>
21+
/// Initializes a new instance of the <see cref="PresetRequestParser"/> class.
22+
/// </summary>
23+
/// <param name="presetOptions">The preset options.</param>
24+
public PresetRequestParser(IOptions<PresetRequestParserOptions> presetOptions) =>
25+
this.presets = ParsePresets(presetOptions.Value.Presets);
2526

27+
/// <inheritdoc/>
2628
public IDictionary<string, string> ParseRequestCommands(HttpContext context)
2729
{
2830
var requestedPreset = context.Request.Query["preset"].ToString();

src/ImageSharp.Web/Commands/PresetRequestParserOptions.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,14 @@
55

66
namespace SixLabors.ImageSharp.Web.Commands
77
{
8+
/// <summary>
9+
/// Configuration options for the <see cref="PresetRequestParser"/>.
10+
/// </summary>
811
public class PresetRequestParserOptions
912
{
13+
/// <summary>
14+
/// Gets or sets the presets, which is a Dictionary of preset names to command query strings.
15+
/// </summary>
1016
public IDictionary<string, string> Presets { get; set; } = new Dictionary<string, string>();
1117
}
1218
}

tests/ImageSharp.Web.Tests/Commands/PresetRequestParserTests.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,16 @@ public void PresetRequestParserExtractsCommands()
1717
{
1818
IDictionary<string, string> expected = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase)
1919
{
20-
{"width", "400"}, {"height", "200"}
20+
{ "width", "400" },
21+
{ "height", "200" }
2122
};
2223

2324
HttpContext context = CreateHttpContext("?preset=Preset1");
2425
IDictionary<string, string> actual = new PresetRequestParser(Options.Create(new PresetRequestParserOptions
2526
{
2627
Presets = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase)
2728
{
28-
{"Preset1", "width=400&height=200"}
29+
{ "Preset1", "width=400&height=200" }
2930
}
3031
})).ParseRequestCommands(context);
3132

@@ -42,7 +43,7 @@ public void PresetRequestParserCommandsWithoutPresetParam()
4243
{
4344
Presets = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase)
4445
{
45-
{"Preset1", "width=400&height=200"}
46+
{ "Preset1", "width=400&height=200" }
4647
}
4748
})).ParseRequestCommands(context);
4849

@@ -59,7 +60,7 @@ public void PresetRequestParserCommandsWithoutMatchingPreset()
5960
{
6061
Presets = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase)
6162
{
62-
{"Preset1", "width=400&height=200"}
63+
{ "Preset1", "width=400&height=200" }
6364
}
6465
})).ParseRequestCommands(context);
6566

0 commit comments

Comments
 (0)