Updates CoreRuntime with better dependencies so we can disable caches, fixes integration test to run multiple callbacks registered for TearDown, ensure we TearDown the runtime.

This commit is contained in:
Shannon
2020-09-04 00:27:43 +10:00
parent 775360ef78
commit 7c78b5b34f
15 changed files with 133 additions and 90 deletions

View File

@@ -146,12 +146,17 @@ namespace Umbraco.Extensions
IHttpContextAccessor httpContextAccessor = new HttpContextAccessor();
services.AddSingleton<IHttpContextAccessor>(httpContextAccessor);
var requestCache = new GenericDictionaryRequestAppCache(() => httpContextAccessor.HttpContext?.Items);
var appCaches = new AppCaches(
new DeepCloneAppCache(new ObjectCacheAppCache()),
requestCache,
new IsolatedCaches(type => new DeepCloneAppCache(new ObjectCacheAppCache())));
services.AddUmbracoCore(webHostEnvironment,
umbContainer,
Assembly.GetEntryAssembly(),
requestCache,
appCaches,
loggingConfig,
out factory);
@@ -165,7 +170,7 @@ namespace Umbraco.Extensions
/// <param name="webHostEnvironment"></param>
/// <param name="umbContainer"></param>
/// <param name="entryAssembly"></param>
/// <param name="requestCache"></param>
/// <param name="appCaches"></param>
/// <param name="httpContextAccessor"></param>
/// <param name="loggingConfiguration"></param>
/// <param name="factory"></param>
@@ -175,10 +180,11 @@ namespace Umbraco.Extensions
IWebHostEnvironment webHostEnvironment,
IRegister umbContainer,
Assembly entryAssembly,
IRequestCache requestCache,
AppCaches appCaches,
ILoggingConfiguration loggingConfiguration,
out IFactory factory)
=> services.AddUmbracoCore(webHostEnvironment, umbContainer, entryAssembly, requestCache, loggingConfiguration, GetCoreRuntime, out factory);
=> services.AddUmbracoCore(webHostEnvironment, umbContainer, entryAssembly, appCaches, loggingConfiguration, GetCoreRuntime, out factory);
/// <summary>
/// Adds the Umbraco Back Core requirements
@@ -187,7 +193,7 @@ namespace Umbraco.Extensions
/// <param name="webHostEnvironment"></param>
/// <param name="umbContainer"></param>
/// <param name="entryAssembly"></param>
/// <param name="requestCache"></param>
/// <param name="appCaches"></param>
/// <param name="httpContextAccessor"></param>
/// <param name="loggingConfiguration"></param>
/// <param name="getRuntime">Delegate to create an <see cref="IRuntime"/></param>
@@ -198,10 +204,10 @@ namespace Umbraco.Extensions
IWebHostEnvironment webHostEnvironment,
IRegister umbContainer,
Assembly entryAssembly,
IRequestCache requestCache,
AppCaches appCaches,
ILoggingConfiguration loggingConfiguration,
// TODO: Yep that's extremely ugly
Func<Configs, IUmbracoVersion, IIOHelper, Core.Logging.ILogger, IProfiler, Core.Hosting.IHostingEnvironment, IBackOfficeInfo, ITypeFinder, IRequestCache, IDbProviderFactoryCreator, IRuntime> getRuntime,
Func<Configs, IUmbracoVersion, IIOHelper, Core.Logging.ILogger, IProfiler, Core.Hosting.IHostingEnvironment, IBackOfficeInfo, ITypeFinder, AppCaches, IDbProviderFactoryCreator, IRuntime> getRuntime,
out IFactory factory)
{
if (services is null) throw new ArgumentNullException(nameof(services));
@@ -242,7 +248,7 @@ namespace Umbraco.Extensions
var typeFinder = CreateTypeFinder(logger, profiler, webHostEnvironment, entryAssembly, configs.TypeFinder());
var runtime = getRuntime(
configs,
configs,
umbracoVersion,
ioHelper,
logger,
@@ -250,7 +256,7 @@ namespace Umbraco.Extensions
hostingEnvironment,
backOfficeInfo,
typeFinder,
requestCache,
appCaches,
dbProviderFactoryCreator);
factory = runtime.Configure(container);
@@ -269,7 +275,7 @@ namespace Umbraco.Extensions
private static IRuntime GetCoreRuntime(
Configs configs, IUmbracoVersion umbracoVersion, IIOHelper ioHelper, Core.Logging.ILogger logger,
IProfiler profiler, Core.Hosting.IHostingEnvironment hostingEnvironment, IBackOfficeInfo backOfficeInfo,
ITypeFinder typeFinder, IRequestCache requestCache, IDbProviderFactoryCreator dbProviderFactoryCreator)
ITypeFinder typeFinder, AppCaches appCaches, IDbProviderFactoryCreator dbProviderFactoryCreator)
{
// Determine if we should use the sql main dom or the default
@@ -285,7 +291,7 @@ namespace Umbraco.Extensions
var mainDom = new MainDom(logger, mainDomLock);
var coreRuntime = new CoreRuntime(
configs,
configs,
umbracoVersion,
ioHelper,
logger,
@@ -296,7 +302,7 @@ namespace Umbraco.Extensions
dbProviderFactoryCreator,
mainDom,
typeFinder,
requestCache);
appCaches);
return coreRuntime;
}