Remove ununsed and unneeded DbProviderFactory CreateFactory(); from IDbProviderFactoryCreator, ensure the app doesn't explode if exceptions are thrown and boot fails

This commit is contained in:
Shannon
2020-05-08 17:30:30 +10:00
parent d899e050fe
commit 12bb68100a
13 changed files with 63 additions and 55 deletions

View File

@@ -173,9 +173,10 @@ namespace Umbraco.Extensions
if (container is null) throw new ArgumentNullException(nameof(container));
if (entryAssembly is null) throw new ArgumentNullException(nameof(entryAssembly));
services.AddUmbracoSqlCeSupport();
services.AddUmbracoSqlServerSupport();
services.AddSingleton<IDbProviderFactoryCreator>(x => new DbProviderFactoryCreator(
x.GetService<Configs>().ConnectionStrings()[Core.Constants.System.UmbracoConnectionName]?.ProviderName,
DbProviderFactories.GetFactory,
x.GetServices<ISqlSyntaxProvider>(),
x.GetServices<IBulkSqlInsertProvider>(),

View File

@@ -1,19 +1,22 @@
using System;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using StackExchange.Profiling;
using Umbraco.Core;
using Umbraco.Web.Common.Middleware;
namespace Umbraco.Extensions
{
public static class UmbracoRequestApplicationBuilderExtensions
{
public static IApplicationBuilder UseUmbracoRequest(this IApplicationBuilder app)
// TODO: Could be internal or part of another call - this is a required system so should't be 'opt-in'
public static IApplicationBuilder UseUmbracoRequestLifetime(this IApplicationBuilder app)
{
if (app == null)
{
throw new ArgumentNullException(nameof(app));
}
if (app == null) throw new ArgumentNullException(nameof(app));
var runtime = app.ApplicationServices.GetRequiredService<IRuntime>();
// can't continue if boot failed
if (runtime.State.Level <= RuntimeLevel.BootFailed) return app;
app.UseMiddleware<UmbracoRequestMiddleware>();
app.UseMiddleware<MiniProfilerMiddleware>();