From 91e2f58822b5fac2653c8c748849807a37a0e761 Mon Sep 17 00:00:00 2001 From: Paul Johnson Date: Tue, 15 Dec 2020 21:47:15 +0000 Subject: [PATCH] Drop ManifestWatcherComposer, Convert CoreInitialComposer to extension on UmbracoBuilder --- .../Compose/ManifestWatcherComposer.cs | 17 --------------- ...tialComposer.cs => CoreInitialServices.cs} | 21 +++++++++++-------- .../{Compose => Runtime}/ManifestWatcher.cs | 2 +- .../Builder/UmbracoBuilderExtensions.cs | 1 + .../Runtime/AspNetCoreComposer.cs | 6 ------ src/Umbraco.Web/Runtime/WebInitialComposer.cs | 7 ------- 6 files changed, 14 insertions(+), 40 deletions(-) delete mode 100644 src/Umbraco.Infrastructure/Compose/ManifestWatcherComposer.cs rename src/Umbraco.Infrastructure/Runtime/{CoreInitialComposer.cs => CoreInitialServices.cs} (96%) rename src/Umbraco.Infrastructure/{Compose => Runtime}/ManifestWatcher.cs (98%) diff --git a/src/Umbraco.Infrastructure/Compose/ManifestWatcherComposer.cs b/src/Umbraco.Infrastructure/Compose/ManifestWatcherComposer.cs deleted file mode 100644 index a94106f6dc..0000000000 --- a/src/Umbraco.Infrastructure/Compose/ManifestWatcherComposer.cs +++ /dev/null @@ -1,17 +0,0 @@ -using Microsoft.Extensions.DependencyInjection; -using Umbraco.Core.Composing; -using Umbraco.Core.DependencyInjection; -using Umbraco.Core.Events; - -namespace Umbraco.Core.Compose -{ - public class ManifestWatcherComposer : ICoreComposer - { - public void Compose(IUmbracoBuilder builder) - { - builder.Services.AddSingleton(); - builder.AddNotificationHandler(factory => factory.GetRequiredService()); - builder.AddNotificationHandler(factory => factory.GetRequiredService()); - } - } -} diff --git a/src/Umbraco.Infrastructure/Runtime/CoreInitialComposer.cs b/src/Umbraco.Infrastructure/Runtime/CoreInitialServices.cs similarity index 96% rename from src/Umbraco.Infrastructure/Runtime/CoreInitialComposer.cs rename to src/Umbraco.Infrastructure/Runtime/CoreInitialServices.cs index e658405400..0fa3250522 100644 --- a/src/Umbraco.Infrastructure/Runtime/CoreInitialComposer.cs +++ b/src/Umbraco.Infrastructure/Runtime/CoreInitialServices.cs @@ -3,8 +3,8 @@ using Examine; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; +using Umbraco.Core; using Umbraco.Core.Cache; -using Umbraco.Core.Composing; using Umbraco.Core.Composing.CompositionExtensions; using Umbraco.Core.Configuration; using Umbraco.Core.Configuration.Grid; @@ -38,7 +38,6 @@ using Umbraco.Core.Templates; using Umbraco.Examine; using Umbraco.Infrastructure.Examine; using Umbraco.Infrastructure.Media; -using Umbraco.Infrastructure.Runtime; using Umbraco.Web; using Umbraco.Web.Actions; using Umbraco.Web.Cache; @@ -63,17 +62,18 @@ using Umbraco.Web.Templates; using Umbraco.Web.Trees; using TextStringValueConverter = Umbraco.Core.PropertyEditors.ValueConverters.TextStringValueConverter; -namespace Umbraco.Core.Runtime +namespace Umbraco.Infrastructure.Runtime { - // core's initial composer composes before all core composers - [ComposeBefore(typeof(ICoreComposer))] - public class CoreInitialComposer : IComposer + public static class CoreInitialServices { - /// - public void Compose(IUmbracoBuilder builder) + public static IUmbracoBuilder AddCoreInitialServices(this IUmbracoBuilder builder) { builder.AddNotificationHandler(); + builder.Services.AddSingleton(); + builder.AddNotificationHandler(factory => factory.GetRequiredService()); + builder.AddNotificationHandler(factory => factory.GetRequiredService()); + // composers builder .ComposeRepositories() @@ -304,7 +304,7 @@ namespace Umbraco.Core.Runtime // register *all* checks, except those marked [HideFromTypeFinder] of course builder.Services.AddUnique(); builder.HealthChecks() - .Add(() => builder.TypeLoader.GetTypes()); + .Add(() => builder.TypeLoader.GetTypes()); builder.WithCollectionBuilder() .Add(() => builder.TypeLoader.GetTypes()); @@ -384,7 +384,10 @@ namespace Umbraco.Core.Runtime builder.Services.AddUnique(); builder.Services.AddUnique(); + builder.Services.AddUnique(); + + return builder; } } } diff --git a/src/Umbraco.Infrastructure/Compose/ManifestWatcher.cs b/src/Umbraco.Infrastructure/Runtime/ManifestWatcher.cs similarity index 98% rename from src/Umbraco.Infrastructure/Compose/ManifestWatcher.cs rename to src/Umbraco.Infrastructure/Runtime/ManifestWatcher.cs index fc18033a28..358dfb2ed5 100644 --- a/src/Umbraco.Infrastructure/Compose/ManifestWatcher.cs +++ b/src/Umbraco.Infrastructure/Runtime/ManifestWatcher.cs @@ -7,7 +7,7 @@ using Umbraco.Core.Events; using Umbraco.Core.Hosting; using Umbraco.Net; -namespace Umbraco.Core.Compose +namespace Umbraco.Infrastructure.Runtime { public sealed class ManifestWatcher : INotificationHandler, diff --git a/src/Umbraco.Web.Common/Builder/UmbracoBuilderExtensions.cs b/src/Umbraco.Web.Common/Builder/UmbracoBuilderExtensions.cs index 4e528bafda..9ecda715ee 100644 --- a/src/Umbraco.Web.Common/Builder/UmbracoBuilderExtensions.cs +++ b/src/Umbraco.Web.Common/Builder/UmbracoBuilderExtensions.cs @@ -150,6 +150,7 @@ namespace Umbraco.Core.DependencyInjection builder.Services.AddUnique(); builder.Services.AddHostedService(factory => factory.GetRequiredService()); + builder.AddCoreInitialServices(); builder.AddComposers(); return builder; diff --git a/src/Umbraco.Web.Common/Runtime/AspNetCoreComposer.cs b/src/Umbraco.Web.Common/Runtime/AspNetCoreComposer.cs index f6849215df..508f4e987f 100644 --- a/src/Umbraco.Web.Common/Runtime/AspNetCoreComposer.cs +++ b/src/Umbraco.Web.Common/Runtime/AspNetCoreComposer.cs @@ -1,22 +1,17 @@ using System.Linq; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Options; using Umbraco.Core; using Umbraco.Core.DependencyInjection; using Umbraco.Core.Composing; -using Umbraco.Core.Configuration.Models; using Umbraco.Core.Diagnostics; using Umbraco.Core.Hosting; using Umbraco.Core.Logging; -using Umbraco.Core.Runtime; using Umbraco.Core.Security; -using Umbraco.Core.Services; using Umbraco.Extensions; using Umbraco.Net; using Umbraco.Web.Common.AspNetCore; using Umbraco.Web.Common.Controllers; -using Umbraco.Web.Common.Formatters; using Umbraco.Web.Common.Install; using Umbraco.Web.Common.Lifetime; using Umbraco.Web.Common.Macros; @@ -38,7 +33,6 @@ namespace Umbraco.Web.Common.Runtime /// Adds/replaces AspNetCore specific services /// [ComposeBefore(typeof(ICoreComposer))] - [ComposeAfter(typeof(CoreInitialComposer))] public class AspNetCoreComposer : ComponentComposer, IComposer { public override void Compose(IUmbracoBuilder builder) diff --git a/src/Umbraco.Web/Runtime/WebInitialComposer.cs b/src/Umbraco.Web/Runtime/WebInitialComposer.cs index 49cff7196e..7528755865 100644 --- a/src/Umbraco.Web/Runtime/WebInitialComposer.cs +++ b/src/Umbraco.Web/Runtime/WebInitialComposer.cs @@ -1,26 +1,19 @@ -using System.Web.Mvc; using System.Web.Security; -using Microsoft.AspNet.SignalR; using Microsoft.Extensions.DependencyInjection; using Umbraco.Core; using Umbraco.Core.DependencyInjection; using Umbraco.Core.Composing; using Umbraco.Core.Dictionary; using Umbraco.Core.Templates; -using Umbraco.Core.Runtime; using Umbraco.Core.Security; using Umbraco.Core.Services; -using Umbraco.Web.Composing.CompositionExtensions; using Umbraco.Web.Macros; -using Umbraco.Web.Mvc; using Umbraco.Web.PublishedCache; using Umbraco.Web.Security; using Umbraco.Web.Security.Providers; namespace Umbraco.Web.Runtime { - // web's initial composer composes after core's, and before all core composers - [ComposeAfter(typeof(CoreInitialComposer))] [ComposeBefore(typeof(ICoreComposer))] public sealed class WebInitialComposer : ComponentComposer {