Skip to content

Commit 42e3c73

Browse files
Document all default configurations
1 parent bcf4ef3 commit 42e3c73

1 file changed

Lines changed: 16 additions & 6 deletions

File tree

samples/ImageSharp.Web.Sample/Startup.cs

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using Microsoft.Extensions.Configuration;
99
using Microsoft.Extensions.DependencyInjection;
1010
using Microsoft.Extensions.Hosting;
11+
using Microsoft.IO;
1112
using SixLabors.ImageSharp.Web.Caching;
1213
using SixLabors.ImageSharp.Web.Commands;
1314
using SixLabors.ImageSharp.Web.DependencyInjection;
@@ -37,13 +38,15 @@ public class Startup
3738
/// </summary>
3839
/// <param name="services">The collection of service desscriptors.</param>
3940
public void ConfigureServices(IServiceCollection services)
40-
=> services.AddImageSharp(); // Add the default service and options
41+
=> services.AddImageSharp(); // Add the default services and options
4142

42-
// Or add the default service and custom options
43+
// Or add the default services and custom options
4344
private void ConfigureDefaultServicesAndCustomOptions(IServiceCollection services)
4445
=> services.AddImageSharp(options =>
4546
{
4647
options.Configuration = Configuration.Default;
48+
options.MemoryStreamManager = new RecyclableMemoryStreamManager();
49+
options.UseInvariantParsingCulture = true;
4750
options.BrowserMaxAge = TimeSpan.FromDays(7);
4851
options.CacheMaxAge = TimeSpan.FromDays(365);
4952
options.CacheHashLength = 12;
@@ -65,25 +68,32 @@ private void ConfigureCustomServicesAndCustomOptions(IServiceCollection services
6568
=> services.AddImageSharp(options =>
6669
{
6770
options.Configuration = Configuration.Default;
71+
options.MemoryStreamManager = new RecyclableMemoryStreamManager();
72+
options.UseInvariantParsingCulture = true;
6873
options.BrowserMaxAge = TimeSpan.FromDays(7);
6974
options.CacheMaxAge = TimeSpan.FromDays(365);
70-
options.CacheHashLength = 8;
75+
options.CacheHashLength = 12;
7176
options.OnParseCommandsAsync = _ => Task.CompletedTask;
7277
options.OnBeforeSaveAsync = _ => Task.CompletedTask;
7378
options.OnProcessedAsync = _ => Task.CompletedTask;
7479
options.OnPrepareResponseAsync = _ => Task.CompletedTask;
7580
})
7681
.SetRequestParser<QueryCollectionRequestParser>()
82+
.SetCache<PhysicalFileSystemCache>()
7783
.Configure<PhysicalFileSystemCacheOptions>(options =>
7884
{
79-
options.CacheFolder = "different-cache";
80-
options.CacheFolderDepth = 6;
85+
options.CacheFolder = "is-cache";
86+
options.CacheFolderDepth = 8;
8187
})
82-
.SetCache<PhysicalFileSystemCache>()
8388
.SetCacheKey<UriRelativeLowerInvariantCacheKey>()
8489
.SetCacheHash<SHA256CacheHash>()
8590
.ClearProviders()
8691
.AddProvider<PhysicalFileSystemProvider>()
92+
.Configure<PhysicalFileSystemProviderOptions>(options =>
93+
{
94+
options.ProviderRootPath = null;
95+
options.ProcessingBehavior = ProcessingBehavior.CommandOnly;
96+
})
8797
.ClearProcessors()
8898
.AddProcessor<ResizeWebProcessor>()
8999
.AddProcessor<FormatWebProcessor>()

0 commit comments

Comments
 (0)