Skip to content

Commit 0ebd51a

Browse files
Fix build
1 parent 3d4e412 commit 0ebd51a

File tree

13 files changed

+1552
-1577
lines changed

13 files changed

+1552
-1577
lines changed

.gitattributes

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,18 +64,19 @@
6464
# Set explicit file behavior to:
6565
# treat as text
6666
# normalize to Unix-style line endings and
67-
# use a union merge when resoling conflicts
67+
# use a union merge when resolving conflicts
6868
###############################################################################
6969
*.csproj text eol=lf merge=union
7070
*.dbproj text eol=lf merge=union
7171
*.fsproj text eol=lf merge=union
7272
*.ncrunchproject text eol=lf merge=union
7373
*.vbproj text eol=lf merge=union
74+
*.shproj text eol=lf merge=union
7475
###############################################################################
7576
# Set explicit file behavior to:
7677
# treat as text
7778
# normalize to Windows-style line endings and
78-
# use a union merge when resoling conflicts
79+
# use a union merge when resolving conflicts
7980
###############################################################################
8081
*.sln text eol=crlf merge=union
8182
###############################################################################
Lines changed: 49 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,74 @@
11
// Copyright (c) Six Labors.
2-
// Licensed under the Apache License, Version 2.0.
2+
// Licensed under the Six Labors Split License.
33

44
using SixLabors.ImageSharp.Web.Caching;
55
using SixLabors.ImageSharp.Web.Commands;
66
using SixLabors.ImageSharp.Web.DependencyInjection;
77
using SixLabors.ImageSharp.Web.Processors;
88
using SixLabors.ImageSharp.Web.Providers;
99

10-
namespace ImageSharp.Web.Sample
10+
namespace ImageSharp.Web.Sample;
11+
12+
/// <summary>
13+
/// The running application.
14+
/// </summary>
15+
public static class Program
1116
{
1217
/// <summary>
13-
/// The running application.
18+
/// The main application entry point.
1419
/// </summary>
15-
public static class Program
20+
/// <param name="args">Argument paramateres.</param>
21+
public static void Main(string[] args)
1622
{
17-
/// <summary>
18-
/// The main application entry point.
19-
/// </summary>
20-
/// <param name="args">Argument paramateres.</param>
21-
public static void Main(string[] args)
22-
{
23-
WebApplicationBuilder builder = WebApplication.CreateBuilder(args);
23+
WebApplicationBuilder builder = WebApplication.CreateBuilder(args);
2424

25-
// Add services to the container.
26-
IServiceCollection services = builder.Services;
27-
services.AddRazorPages();
25+
// Add services to the container.
26+
IServiceCollection services = builder.Services;
27+
services.AddRazorPages();
2828

29-
// TODO: Enable HMAC
30-
services.AddImageSharp(options => options.HMACSecretKey = new byte[] { 1, 2, 3, 4, 5 })
31-
.SetRequestParser<QueryCollectionRequestParser>()
32-
.Configure<PhysicalFileSystemCacheOptions>(options =>
33-
{
34-
options.CacheRootPath = null;
35-
options.CacheFolder = "is-cache";
36-
options.CacheFolderDepth = 8;
37-
})
38-
.SetCache<PhysicalFileSystemCache>()
39-
.SetCacheKey<UriRelativeLowerInvariantCacheKey>()
40-
.SetCacheHash<SHA256CacheHash>()
41-
.Configure<PhysicalFileSystemProviderOptions>(options => options.ProviderRootPath = null)
42-
.AddProvider<PhysicalFileSystemProvider>()
43-
.AddProcessor<ResizeWebProcessor>()
44-
.AddProcessor<FormatWebProcessor>()
45-
.AddProcessor<BackgroundColorWebProcessor>()
46-
.AddProcessor<QualityWebProcessor>()
47-
.AddProcessor<AutoOrientWebProcessor>();
29+
// TODO: Enable HMAC
30+
services.AddImageSharp(options => options.HMACSecretKey = new byte[] { 1, 2, 3, 4, 5 })
31+
.SetRequestParser<QueryCollectionRequestParser>()
32+
.Configure<PhysicalFileSystemCacheOptions>(options =>
33+
{
34+
options.CacheRootPath = null;
35+
options.CacheFolder = "is-cache";
36+
options.CacheFolderDepth = 8;
37+
})
38+
.SetCache<PhysicalFileSystemCache>()
39+
.SetCacheKey<UriRelativeLowerInvariantCacheKey>()
40+
.SetCacheHash<SHA256CacheHash>()
41+
.Configure<PhysicalFileSystemProviderOptions>(options => options.ProviderRootPath = null)
42+
.AddProvider<PhysicalFileSystemProvider>()
43+
.AddProcessor<ResizeWebProcessor>()
44+
.AddProcessor<FormatWebProcessor>()
45+
.AddProcessor<BackgroundColorWebProcessor>()
46+
.AddProcessor<QualityWebProcessor>()
47+
.AddProcessor<AutoOrientWebProcessor>();
4848

49-
WebApplication app = builder.Build();
49+
WebApplication app = builder.Build();
5050

51-
// Configure the HTTP request pipeline.
52-
if (!app.Environment.IsDevelopment())
53-
{
54-
app.UseExceptionHandler("/Error");
51+
// Configure the HTTP request pipeline.
52+
if (!app.Environment.IsDevelopment())
53+
{
54+
app.UseExceptionHandler("/Error");
5555

56-
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
57-
app.UseHsts();
58-
}
56+
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
57+
app.UseHsts();
58+
}
5959

60-
app.UseHttpsRedirection();
60+
app.UseHttpsRedirection();
6161

62-
app.UseImageSharp();
62+
app.UseImageSharp();
6363

64-
app.UseStaticFiles();
64+
app.UseStaticFiles();
6565

66-
app.UseRouting();
66+
app.UseRouting();
6767

68-
app.UseAuthorization();
68+
app.UseAuthorization();
6969

70-
app.MapRazorPages();
70+
app.MapRazorPages();
7171

72-
app.Run();
73-
}
72+
app.Run();
7473
}
75-
}
74+
}
Lines changed: 108 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
// Copyright (c) Six Labors.
2-
// Licensed under the Apache License, Version 2.0.
2+
// Licensed under the Six Labors Split License.
33

4-
using System;
54
using Microsoft.Extensions.DependencyInjection;
6-
using Microsoft.Extensions.DependencyInjection.Extensions;
7-
using Microsoft.Extensions.Options;
85
using SixLabors.ImageSharp.Web.Caching;
96
using SixLabors.ImageSharp.Web.Commands;
107
using SixLabors.ImageSharp.Web.Commands.Converters;
@@ -13,116 +10,115 @@
1310
using SixLabors.ImageSharp.Web.Providers;
1411
using SixLabors.ImageSharp.Web.Synchronization;
1512

16-
namespace SixLabors.ImageSharp.Web.DependencyInjection
13+
namespace SixLabors.ImageSharp.Web.DependencyInjection;
14+
15+
/// <summary>
16+
/// Extension methods for <see cref="IServiceCollection"/> to simplify middleware service registration.
17+
/// </summary>
18+
public static class ServiceCollectionExtensions
1719
{
1820
/// <summary>
19-
/// Extension methods for <see cref="IServiceCollection"/> to simplify middleware service registration.
21+
/// Adds ImageSharp services to the specified <see cref="IServiceCollection" /> with the default options.
2022
/// </summary>
21-
public static class ServiceCollectionExtensions
23+
/// <param name="services">The <see cref="IServiceCollection" /> to add services to.</param>
24+
/// <returns>An <see cref="IImageSharpBuilder"/> that can be used to further configure the ImageSharp services.</returns>
25+
public static IImageSharpBuilder AddImageSharp(this IServiceCollection services)
26+
=> AddImageSharp(services, _ => { });
27+
28+
/// <summary>
29+
/// Adds ImageSharp services to the specified <see cref="IServiceCollection" /> with the given options.
30+
/// </summary>
31+
/// <param name="services">The <see cref="IServiceCollection" /> to add services to.</param>
32+
/// <param name="setupAction">An <see cref="Action{ImageSharpMiddlewareOptions}"/> to configure the provided <see cref="ImageSharpMiddlewareOptions"/>.</param>
33+
/// <returns>An <see cref="IImageSharpBuilder"/> that can be used to further configure the ImageSharp services.</returns>
34+
public static IImageSharpBuilder AddImageSharp(
35+
this IServiceCollection services,
36+
Action<ImageSharpMiddlewareOptions> setupAction)
37+
{
38+
Guard.NotNull(services, nameof(services));
39+
Guard.NotNull(setupAction, nameof(setupAction));
40+
41+
IImageSharpBuilder builder = new ImageSharpBuilder(services);
42+
43+
AddDefaultServices(builder, setupAction);
44+
45+
return builder;
46+
}
47+
48+
private static void AddDefaultServices(
49+
IImageSharpBuilder builder,
50+
Action<ImageSharpMiddlewareOptions> setupAction)
2251
{
23-
/// <summary>
24-
/// Adds ImageSharp services to the specified <see cref="IServiceCollection" /> with the default options.
25-
/// </summary>
26-
/// <param name="services">The <see cref="IServiceCollection" /> to add services to.</param>
27-
/// <returns>An <see cref="IImageSharpBuilder"/> that can be used to further configure the ImageSharp services.</returns>
28-
public static IImageSharpBuilder AddImageSharp(this IServiceCollection services)
29-
=> AddImageSharp(services, _ => { });
30-
31-
/// <summary>
32-
/// Adds ImageSharp services to the specified <see cref="IServiceCollection" /> with the given options.
33-
/// </summary>
34-
/// <param name="services">The <see cref="IServiceCollection" /> to add services to.</param>
35-
/// <param name="setupAction">An <see cref="Action{ImageSharpMiddlewareOptions}"/> to configure the provided <see cref="ImageSharpMiddlewareOptions"/>.</param>
36-
/// <returns>An <see cref="IImageSharpBuilder"/> that can be used to further configure the ImageSharp services.</returns>
37-
public static IImageSharpBuilder AddImageSharp(
38-
this IServiceCollection services,
39-
Action<ImageSharpMiddlewareOptions> setupAction)
40-
{
41-
Guard.NotNull(services, nameof(services));
42-
Guard.NotNull(setupAction, nameof(setupAction));
43-
44-
IImageSharpBuilder builder = new ImageSharpBuilder(services);
45-
46-
AddDefaultServices(builder, setupAction);
47-
48-
return builder;
49-
}
50-
51-
private static void AddDefaultServices(
52-
IImageSharpBuilder builder,
53-
Action<ImageSharpMiddlewareOptions> setupAction)
54-
{
55-
builder.Services.Configure(setupAction);
56-
57-
builder.Services.AddSingleton<FormatUtilities>();
58-
59-
builder.Services.AddSingleton<AsyncKeyReaderWriterLock<string>>();
60-
61-
builder.SetRequestParser<QueryCollectionRequestParser>();
62-
63-
builder.Services.AddSingleton<RequestAuthorizationUtilities>();
64-
65-
builder.SetCache<PhysicalFileSystemCache>();
66-
67-
builder.SetCacheKey<UriRelativeLowerInvariantCacheKey>();
68-
69-
builder.SetCacheHash<SHA256CacheHash>();
70-
71-
builder.AddProvider<PhysicalFileSystemProvider>();
72-
73-
builder.AddProcessor<ResizeWebProcessor>()
74-
.AddProcessor<FormatWebProcessor>()
75-
.AddProcessor<BackgroundColorWebProcessor>()
76-
.AddProcessor<QualityWebProcessor>()
77-
.AddProcessor<AutoOrientWebProcessor>();
78-
79-
builder.AddConverter<IntegralNumberConverter<sbyte>>();
80-
builder.AddConverter<IntegralNumberConverter<byte>>();
81-
builder.AddConverter<IntegralNumberConverter<short>>();
82-
builder.AddConverter<IntegralNumberConverter<ushort>>();
83-
builder.AddConverter<IntegralNumberConverter<int>>();
84-
builder.AddConverter<IntegralNumberConverter<uint>>();
85-
builder.AddConverter<IntegralNumberConverter<long>>();
86-
builder.AddConverter<IntegralNumberConverter<ulong>>();
87-
88-
builder.AddConverter<SimpleCommandConverter<decimal>>();
89-
builder.AddConverter<SimpleCommandConverter<float>>();
90-
builder.AddConverter<SimpleCommandConverter<double>>();
91-
builder.AddConverter<SimpleCommandConverter<string>>();
92-
builder.AddConverter<SimpleCommandConverter<bool>>();
93-
94-
builder.AddConverter<ArrayConverter<sbyte>>();
95-
builder.AddConverter<ArrayConverter<byte>>();
96-
builder.AddConverter<ArrayConverter<short>>();
97-
builder.AddConverter<ArrayConverter<ushort>>();
98-
builder.AddConverter<ArrayConverter<int>>();
99-
builder.AddConverter<ArrayConverter<uint>>();
100-
builder.AddConverter<ArrayConverter<long>>();
101-
builder.AddConverter<ArrayConverter<ulong>>();
102-
builder.AddConverter<ArrayConverter<decimal>>();
103-
builder.AddConverter<ArrayConverter<float>>();
104-
builder.AddConverter<ArrayConverter<double>>();
105-
builder.AddConverter<ArrayConverter<string>>();
106-
builder.AddConverter<ArrayConverter<bool>>();
107-
108-
builder.AddConverter<ListConverter<sbyte>>();
109-
builder.AddConverter<ListConverter<byte>>();
110-
builder.AddConverter<ListConverter<short>>();
111-
builder.AddConverter<ListConverter<ushort>>();
112-
builder.AddConverter<ListConverter<int>>();
113-
builder.AddConverter<ListConverter<uint>>();
114-
builder.AddConverter<ListConverter<long>>();
115-
builder.AddConverter<ListConverter<ulong>>();
116-
builder.AddConverter<ListConverter<decimal>>();
117-
builder.AddConverter<ListConverter<float>>();
118-
builder.AddConverter<ListConverter<double>>();
119-
builder.AddConverter<ListConverter<string>>();
120-
builder.AddConverter<ListConverter<bool>>();
121-
122-
builder.AddConverter<ColorConverter>();
123-
builder.AddConverter<EnumConverter>();
124-
125-
builder.Services.AddSingleton<CommandParser>();
126-
}
52+
builder.Services.Configure(setupAction);
53+
54+
builder.Services.AddSingleton<FormatUtilities>();
55+
56+
builder.Services.AddSingleton<AsyncKeyReaderWriterLock<string>>();
57+
58+
builder.SetRequestParser<QueryCollectionRequestParser>();
59+
60+
builder.Services.AddSingleton<RequestAuthorizationUtilities>();
61+
62+
builder.SetCache<PhysicalFileSystemCache>();
63+
64+
builder.SetCacheKey<UriRelativeLowerInvariantCacheKey>();
65+
66+
builder.SetCacheHash<SHA256CacheHash>();
67+
68+
builder.AddProvider<PhysicalFileSystemProvider>();
69+
70+
builder.AddProcessor<ResizeWebProcessor>()
71+
.AddProcessor<FormatWebProcessor>()
72+
.AddProcessor<BackgroundColorWebProcessor>()
73+
.AddProcessor<QualityWebProcessor>()
74+
.AddProcessor<AutoOrientWebProcessor>();
75+
76+
builder.AddConverter<IntegralNumberConverter<sbyte>>();
77+
builder.AddConverter<IntegralNumberConverter<byte>>();
78+
builder.AddConverter<IntegralNumberConverter<short>>();
79+
builder.AddConverter<IntegralNumberConverter<ushort>>();
80+
builder.AddConverter<IntegralNumberConverter<int>>();
81+
builder.AddConverter<IntegralNumberConverter<uint>>();
82+
builder.AddConverter<IntegralNumberConverter<long>>();
83+
builder.AddConverter<IntegralNumberConverter<ulong>>();
84+
85+
builder.AddConverter<SimpleCommandConverter<decimal>>();
86+
builder.AddConverter<SimpleCommandConverter<float>>();
87+
builder.AddConverter<SimpleCommandConverter<double>>();
88+
builder.AddConverter<SimpleCommandConverter<string>>();
89+
builder.AddConverter<SimpleCommandConverter<bool>>();
90+
91+
builder.AddConverter<ArrayConverter<sbyte>>();
92+
builder.AddConverter<ArrayConverter<byte>>();
93+
builder.AddConverter<ArrayConverter<short>>();
94+
builder.AddConverter<ArrayConverter<ushort>>();
95+
builder.AddConverter<ArrayConverter<int>>();
96+
builder.AddConverter<ArrayConverter<uint>>();
97+
builder.AddConverter<ArrayConverter<long>>();
98+
builder.AddConverter<ArrayConverter<ulong>>();
99+
builder.AddConverter<ArrayConverter<decimal>>();
100+
builder.AddConverter<ArrayConverter<float>>();
101+
builder.AddConverter<ArrayConverter<double>>();
102+
builder.AddConverter<ArrayConverter<string>>();
103+
builder.AddConverter<ArrayConverter<bool>>();
104+
105+
builder.AddConverter<ListConverter<sbyte>>();
106+
builder.AddConverter<ListConverter<byte>>();
107+
builder.AddConverter<ListConverter<short>>();
108+
builder.AddConverter<ListConverter<ushort>>();
109+
builder.AddConverter<ListConverter<int>>();
110+
builder.AddConverter<ListConverter<uint>>();
111+
builder.AddConverter<ListConverter<long>>();
112+
builder.AddConverter<ListConverter<ulong>>();
113+
builder.AddConverter<ListConverter<decimal>>();
114+
builder.AddConverter<ListConverter<float>>();
115+
builder.AddConverter<ListConverter<double>>();
116+
builder.AddConverter<ListConverter<string>>();
117+
builder.AddConverter<ListConverter<bool>>();
118+
119+
builder.AddConverter<ColorConverter>();
120+
builder.AddConverter<EnumConverter>();
121+
122+
builder.Services.AddSingleton<CommandParser>();
127123
}
128-
}
124+
}

0 commit comments

Comments
 (0)