diff --git a/src/DbLocalizationProvider.EPiServer/DbLocalizationConfigurationContext.cs b/src/DbLocalizationProvider.EPiServer/DbLocalizationConfigurationContext.cs new file mode 100644 index 0000000..1392e75 --- /dev/null +++ b/src/DbLocalizationProvider.EPiServer/DbLocalizationConfigurationContext.cs @@ -0,0 +1,14 @@ +using DbLocalizationProvider.Cache; + +namespace DbLocalizationProvider.EPiServer; + +/// +/// Configuration context for DbLocalizationProvider.EPiServer. +/// +public class DbLocalizationConfigurationContext +{ + /// + /// Allows to override internal cache implementation, if problems with default EPiServer implementation arise. + /// + public ICache InnerCache { get; set; } = new EPiServerCache(); +} diff --git a/src/DbLocalizationProvider.EPiServer/IServiceCollectionExtensions.cs b/src/DbLocalizationProvider.EPiServer/IServiceCollectionExtensions.cs index cbbbf4a..e0c69d3 100644 --- a/src/DbLocalizationProvider.EPiServer/IServiceCollectionExtensions.cs +++ b/src/DbLocalizationProvider.EPiServer/IServiceCollectionExtensions.cs @@ -1,6 +1,7 @@ // Copyright (c) Valdis Iljuconoks. All rights reserved. // Licensed under Apache-2.0. See the LICENSE file in the project root for more information +using System; using System.Globalization; using System.Linq; using DbLocalizationProvider.AspNetCore; @@ -23,10 +24,15 @@ public static class IServiceCollectionExtensions /// Adds Optimizely support for DbLocalizationProvider. /// /// Provider builder interface (to capture context and service collection). + /// If required, modify configurations using the /// Service collection to support fluent API. - public static IDbLocalizationProviderBuilder AddOptimizely(this IDbLocalizationProviderBuilder builder) + public static IDbLocalizationProviderBuilder AddOptimizely(this IDbLocalizationProviderBuilder builder, Action? setup = null) { - builder.Context._baseCacheManager.SetInnerManager(new EPiServerCache()); + var configContext = new DbLocalizationConfigurationContext(); + + setup?.Invoke(configContext); + + builder.Context._baseCacheManager.SetInnerManager(configContext.InnerCache); builder.Services.AddTransient();