Skip to content

Commit 3f154bc

Browse files
Pass behavior via constructor
1 parent e987deb commit 3f154bc

3 files changed

Lines changed: 10 additions & 7 deletions

File tree

src/ImageSharp.Web/Providers/FileProviderImageProvider.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,20 @@ public abstract class FileProviderImageProvider : IImageProvider
2929
/// Initializes a new instance of the <see cref="FileProviderImageProvider"/> class.
3030
/// </summary>
3131
/// <param name="fileProvider">The file provider.</param>
32+
/// <param name="processingBehavior">The processing behavior.</param>
3233
/// <param name="formatUtilities">Contains various format helper methods based on the current configuration.</param>
33-
protected FileProviderImageProvider(IFileProvider fileProvider, FormatUtilities formatUtilities)
34+
protected FileProviderImageProvider(IFileProvider fileProvider, ProcessingBehavior processingBehavior, FormatUtilities formatUtilities)
3435
{
3536
Guard.NotNull(fileProvider, nameof(fileProvider));
3637
Guard.NotNull(formatUtilities, nameof(formatUtilities));
3738

3839
this.fileProvider = fileProvider;
3940
this.formatUtilities = formatUtilities;
41+
this.ProcessingBehavior = processingBehavior;
4042
}
4143

4244
/// <inheritdoc/>
43-
public virtual ProcessingBehavior ProcessingBehavior { get; protected set; } = ProcessingBehavior.CommandOnly;
45+
public virtual ProcessingBehavior ProcessingBehavior { get; }
4446

4547
/// <inheritdoc/>
4648
public virtual Func<HttpContext, bool> Match { get; set; } = _ => true;

src/ImageSharp.Web/Providers/PhysicalFileSystemProvider.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@ public PhysicalFileSystemProvider(
2828
IWebHostEnvironment environment,
2929
#endif
3030
FormatUtilities formatUtilities)
31-
: base(GetProvider(options?.Value, environment), formatUtilities)
32-
=> this.ProcessingBehavior = options.Value.ProcessingBehavior;
31+
: base(GetProvider(options, environment), options.Value.ProcessingBehavior, formatUtilities)
32+
{
33+
}
3334

3435
/// <summary>
3536
/// Determine the provider root path
@@ -56,7 +57,7 @@ internal static string GetProviderRoot(PhysicalFileSystemProviderOptions options
5657
}
5758

5859
private static PhysicalFileProvider GetProvider(
59-
PhysicalFileSystemProviderOptions options,
60+
IOptions<PhysicalFileSystemProviderOptions> options,
6061
#if NETCOREAPP2_1
6162
IHostingEnvironment environment)
6263
#else
@@ -65,7 +66,7 @@ private static PhysicalFileProvider GetProvider(
6566
{
6667
Guard.NotNull(options, nameof(options));
6768
Guard.NotNull(environment, nameof(environment));
68-
return new(GetProviderRoot(options, environment.WebRootPath, environment.ContentRootPath));
69+
return new(GetProviderRoot(options.Value, environment.WebRootPath, environment.ContentRootPath));
6970
}
7071
}
7172
}

src/ImageSharp.Web/Providers/WebRootImageProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public WebRootImageProvider(
2222
IWebHostEnvironment environment,
2323
#endif
2424
FormatUtilities formatUtilities)
25-
: base(environment.WebRootFileProvider, formatUtilities)
25+
: base(environment.WebRootFileProvider, ProcessingBehavior.CommandOnly, formatUtilities)
2626
{
2727
}
2828
}

0 commit comments

Comments
 (0)