* Run code cleanup * Run dotnet format * Start manual cleanup in Web.Common * Finish up manual cleanup * Fix tests * Fix up InMemoryModelFactory.cs * Inject proper macroRenderer * Update src/Umbraco.Web.Common/Filters/JsonDateTimeFormatAttribute.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Web.Common/Filters/ValidateUmbracoFormRouteStringAttribute.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Fix based on review Co-authored-by: Nikolaj Geisle <niko737@edu.ucl.dk> Co-authored-by: Mole <nikolajlauridsen@protonmail.ch>
38 lines
1.4 KiB
C#
38 lines
1.4 KiB
C#
using Microsoft.Extensions.Hosting;
|
|
using Microsoft.Extensions.Options;
|
|
using SixLabors.ImageSharp.Web.Caching;
|
|
using Umbraco.Cms.Core.Configuration.Models;
|
|
using Umbraco.Cms.Core.Extensions;
|
|
|
|
namespace Umbraco.Cms.Web.Common.DependencyInjection;
|
|
|
|
/// <summary>
|
|
/// Configures the ImageSharp physical file system cache options.
|
|
/// </summary>
|
|
/// <seealso cref="IConfigureOptions{PhysicalFileSystemCacheOptions}" />
|
|
public sealed class ConfigurePhysicalFileSystemCacheOptions : IConfigureOptions<PhysicalFileSystemCacheOptions>
|
|
{
|
|
private readonly IHostEnvironment _hostEnvironment;
|
|
private readonly ImagingSettings _imagingSettings;
|
|
|
|
/// <summary>
|
|
/// Initializes a new instance of the <see cref="ConfigurePhysicalFileSystemCacheOptions" /> class.
|
|
/// </summary>
|
|
/// <param name="imagingSettings">The Umbraco imaging settings.</param>
|
|
/// <param name="hostEnvironment">The host environment.</param>
|
|
public ConfigurePhysicalFileSystemCacheOptions(
|
|
IOptions<ImagingSettings> imagingSettings,
|
|
IHostEnvironment hostEnvironment)
|
|
{
|
|
_imagingSettings = imagingSettings.Value;
|
|
_hostEnvironment = hostEnvironment;
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public void Configure(PhysicalFileSystemCacheOptions options)
|
|
{
|
|
options.CacheFolder = _hostEnvironment.MapPathContentRoot(_imagingSettings.Cache.CacheFolder);
|
|
options.CacheFolderDepth = _imagingSettings.Cache.CacheFolderDepth;
|
|
}
|
|
}
|