Merge branch 'netcore/feature/AB3649-move-manifest-stuff' into netcore/feature/AB3594_move_exsiting_configuration_to_own_project

This commit is contained in:
Bjarke Berg
2019-11-12 14:11:08 +01:00
266 changed files with 2261 additions and 2414 deletions

View File

@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Configuration;
using System.Diagnostics;
using System.IO;
using System.Web;
using System.Web.Hosting;
using Umbraco.Core.Cache;
@@ -43,6 +44,16 @@ namespace Umbraco.Core.Runtime
/// </summary>
protected IProfilingLogger ProfilingLogger { get; private set; }
/// <summary>
/// Gets the <see cref="ITypeFinder"/>
/// </summary>
protected ITypeFinder TypeFinder { get; private set; }
/// <summary>
/// Gets the <see cref="IIOHelper"/>
/// </summary>
protected IIOHelper IOHelper { get; private set; }
/// <inheritdoc />
public IRuntimeState State => _state;
@@ -54,9 +65,22 @@ namespace Umbraco.Core.Runtime
// loggers
var logger = Logger = GetLogger();
if (logger == null)
throw new InvalidOperationException($"The object returned from {nameof(GetLogger)} cannot be null");
var profiler = Profiler = GetProfiler();
if (profiler == null)
throw new InvalidOperationException($"The object returned from {nameof(GetProfiler)} cannot be null");
var profilingLogger = ProfilingLogger = new ProfilingLogger(logger, profiler);
IOHelper = GetIOHelper();
if (IOHelper == null)
throw new InvalidOperationException($"The object returned from {nameof(GetIOHelper)} cannot be null");
TypeFinder = GetTypeFinder();
if (TypeFinder == null)
throw new InvalidOperationException($"The object returned from {nameof(GetTypeFinder)} cannot be null");
// the boot loader boots using a container scope, so anything that is PerScope will
// be disposed after the boot loader has booted, and anything else will remain.
// note that this REQUIRES that perWebRequestScope has NOT been enabled yet, else
@@ -112,8 +136,8 @@ namespace Umbraco.Core.Runtime
// configs
var configs = GetConfigs(configsFactory);
// type loader
var typeLoader = new TypeLoader(appCaches.RuntimeCache, configs.Global().LocalTempPath, ProfilingLogger);
// type finder/loader
var typeLoader = new TypeLoader(IOHelper, TypeFinder, appCaches.RuntimeCache, new DirectoryInfo(configs.Global().LocalTempPath), ProfilingLogger);
// runtime state
// beware! must use '() => _factory.GetInstance<T>()' and NOT '_factory.GetInstance<T>'
@@ -131,7 +155,7 @@ namespace Umbraco.Core.Runtime
// create the composition
composition = new Composition(register, typeLoader, ProfilingLogger, _state, configs);
composition.RegisterEssentials(Logger, Profiler, ProfilingLogger, mainDom, appCaches, databaseFactory, typeLoader, _state);
composition.RegisterEssentials(Logger, Profiler, ProfilingLogger, mainDom, appCaches, databaseFactory, typeLoader, _state, TypeFinder, IOHelper);
// run handlers
RuntimeOptions.DoRuntimeEssentials(composition, appCaches, typeLoader, databaseFactory);
@@ -153,7 +177,7 @@ namespace Umbraco.Core.Runtime
composers.Compose();
// create the factory
_factory = Current.Factory = CurrentCore.Factory = composition.CreateFactory();
_factory = Current.Factory = composition.CreateFactory();
// create & initialize the components
_components = _factory.GetInstance<ComponentCollection>();
@@ -178,7 +202,7 @@ namespace Umbraco.Core.Runtime
{
try
{
_factory = Current.Factory = CurrentCore.Factory = composition?.CreateFactory();
_factory = Current.Factory = composition?.CreateFactory();
}
catch { /* yea */ }
}
@@ -289,7 +313,6 @@ namespace Umbraco.Core.Runtime
/// </summary>
public virtual void Compose(Composition composition)
{
// nothing
}
#region Getters
@@ -314,6 +337,20 @@ namespace Umbraco.Core.Runtime
protected virtual IProfiler GetProfiler()
=> new LogProfiler(Logger);
/// <summary>
/// Gets a <see cref="ITypeFinder"/>
/// </summary>
/// <returns></returns>
protected virtual ITypeFinder GetTypeFinder()
=> new TypeFinder(Logger);
/// <summary>
/// Gets a <see cref="IIOHelper"/>
/// </summary>
/// <returns></returns>
protected virtual IIOHelper GetIOHelper()
=> Umbraco.Core.IO.IOHelper.Default;
/// <summary>
/// Gets the application caches.
/// </summary>
@@ -324,9 +361,9 @@ namespace Umbraco.Core.Runtime
// is overridden by the web runtime
return new AppCaches(
new DeepCloneAppCache(new ObjectCacheAppCache()),
new DeepCloneAppCache(new ObjectCacheAppCache(TypeFinder)),
NoAppCache.Instance,
new IsolatedCaches(type => new DeepCloneAppCache(new ObjectCacheAppCache())));
new IsolatedCaches(type => new DeepCloneAppCache(new ObjectCacheAppCache(TypeFinder))));
}
// by default, returns null, meaning that Umbraco should auto-detect the application root path.