NetCore: MSDI refactor phase 2 (#9280)
* Moved adapters from Infra -> Core * Allow Composition to accept a service collection instead of an IRegister * Composition no longer takes IRegister as constructor arg all tests passing * Composition no longer implements IRegister * Lose _uniques in Composition * lose Composition OnCreatingFactory actions * Clean up UmbracoCoreServiceCollectionExtensions & Composition Less IFactory * LightInject gone where TFW == netstandard2.0 || TFW == netcoreapp3.1 * Resolve dead code issues * Rename IFactory methods to match IServiceProvider so they can be trivially swapped later. * Rename IFactory methods to match IServiceProvider so they can be trivially swapped later (continued) Thought the counts were low, it's mostly extension method usage
This commit is contained in:
@@ -42,10 +42,6 @@ namespace Umbraco.Extensions
|
||||
if (!app.UmbracoCanBoot()) return app;
|
||||
|
||||
var runtime = app.ApplicationServices.GetRequiredService<IRuntime>();
|
||||
if (runtime is CoreRuntime coreRuntime)
|
||||
{
|
||||
coreRuntime.ReplaceFactory(app.ApplicationServices);
|
||||
}
|
||||
|
||||
// Register a listener for application shutdown in order to terminate the runtime
|
||||
var hostLifetime = app.ApplicationServices.GetRequiredService<IApplicationShutdownRegistry>();
|
||||
@@ -57,7 +53,7 @@ namespace Umbraco.Extensions
|
||||
LogContext.Push(threadAbortEnricher); // NOTE: We are not in a using clause because we are not removing it, it is on the global context
|
||||
|
||||
// Start the runtime!
|
||||
runtime.Start();
|
||||
runtime.Start(app.ApplicationServices);
|
||||
|
||||
return app;
|
||||
}
|
||||
|
||||
@@ -116,9 +116,8 @@ namespace Umbraco.Extensions
|
||||
Assembly entryAssembly,
|
||||
AppCaches appCaches,
|
||||
ILoggingConfiguration loggingConfiguration,
|
||||
IConfiguration configuration,
|
||||
out IFactory factory)
|
||||
=> services.AddUmbracoCore(webHostEnvironment, umbContainer, entryAssembly, appCaches, loggingConfiguration, configuration, GetCoreRuntime, out factory);
|
||||
IConfiguration configuration)
|
||||
=> services.AddUmbracoCore(webHostEnvironment, umbContainer, entryAssembly, appCaches, loggingConfiguration, configuration, GetCoreRuntime);
|
||||
|
||||
/// <summary>
|
||||
/// Adds the Umbraco Configuration requirements
|
||||
@@ -160,18 +159,6 @@ namespace Umbraco.Extensions
|
||||
return services;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds the Umbraco Back Core requirements
|
||||
/// </summary>
|
||||
/// <param name="services"></param>
|
||||
/// <param name="webHostEnvironment"></param>
|
||||
/// <param name="configuration"></param>
|
||||
/// <returns></returns>
|
||||
public static IServiceCollection AddUmbracoCore(this IServiceCollection services, IWebHostEnvironment webHostEnvironment, IConfiguration configuration)
|
||||
{
|
||||
return services.AddUmbracoCore(webHostEnvironment, configuration, out _);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds the Umbraco Back Core requirements
|
||||
/// </summary>
|
||||
@@ -180,7 +167,7 @@ namespace Umbraco.Extensions
|
||||
/// <param name="configuration"></param>
|
||||
/// <param name="factory"></param>
|
||||
/// <returns></returns>
|
||||
public static IServiceCollection AddUmbracoCore(this IServiceCollection services, IWebHostEnvironment webHostEnvironment, IConfiguration configuration, out IFactory factory)
|
||||
public static IServiceCollection AddUmbracoCore(this IServiceCollection services, IWebHostEnvironment webHostEnvironment, IConfiguration configuration)
|
||||
{
|
||||
|
||||
var loggingConfig = new LoggingConfiguration(
|
||||
@@ -209,8 +196,7 @@ namespace Umbraco.Extensions
|
||||
appCaches,
|
||||
loggingConfig,
|
||||
configuration,
|
||||
GetCoreRuntime,
|
||||
out factory);
|
||||
GetCoreRuntime);
|
||||
|
||||
return services;
|
||||
}
|
||||
@@ -237,8 +223,7 @@ namespace Umbraco.Extensions
|
||||
ILoggingConfiguration loggingConfiguration,
|
||||
IConfiguration configuration,
|
||||
//TODO: Yep that's extremely ugly
|
||||
Func<GlobalSettings, ConnectionStrings, IUmbracoVersion, IIOHelper, ILoggerFactory, IProfiler, IHostingEnvironment, IBackOfficeInfo, ITypeFinder, AppCaches, IDbProviderFactoryCreator, IRuntime> getRuntime,
|
||||
out IFactory factory)
|
||||
Func<GlobalSettings, ConnectionStrings, IUmbracoVersion, IIOHelper, ILoggerFactory, IProfiler, IHostingEnvironment, IBackOfficeInfo, ITypeFinder, AppCaches, IDbProviderFactoryCreator, IRuntime> getRuntime)
|
||||
{
|
||||
if (services is null) throw new ArgumentNullException(nameof(services));
|
||||
var container = umbContainer;
|
||||
@@ -306,7 +291,7 @@ namespace Umbraco.Extensions
|
||||
appCaches,
|
||||
dbProviderFactoryCreator);
|
||||
|
||||
factory = coreRuntime.Configure(container);
|
||||
coreRuntime.Configure(services);
|
||||
|
||||
return services;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user