Drop ManifestWatcherComposer, Convert CoreInitialComposer to extension on UmbracoBuilder

This commit is contained in:
Paul Johnson
2020-12-15 21:47:15 +00:00
parent ef310920cb
commit 91e2f58822
6 changed files with 14 additions and 40 deletions

View File

@@ -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<ManifestWatcher>();
builder.AddNotificationHandler<UmbracoApplicationStarting, ManifestWatcher>(factory => factory.GetRequiredService<ManifestWatcher>());
builder.AddNotificationHandler<UmbracoApplicationStopping, ManifestWatcher>(factory => factory.GetRequiredService<ManifestWatcher>());
}
}
}

View File

@@ -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
{
/// <inheritdoc/>
public void Compose(IUmbracoBuilder builder)
public static IUmbracoBuilder AddCoreInitialServices(this IUmbracoBuilder builder)
{
builder.AddNotificationHandler<UmbracoApplicationStarting, EssentialDirectoryCreator>();
builder.Services.AddSingleton<ManifestWatcher>();
builder.AddNotificationHandler<UmbracoApplicationStarting, ManifestWatcher>(factory => factory.GetRequiredService<ManifestWatcher>());
builder.AddNotificationHandler<UmbracoApplicationStopping, ManifestWatcher>(factory => factory.GetRequiredService<ManifestWatcher>());
// composers
builder
.ComposeRepositories()
@@ -304,7 +304,7 @@ namespace Umbraco.Core.Runtime
// register *all* checks, except those marked [HideFromTypeFinder] of course
builder.Services.AddUnique<IMarkdownToHtmlConverter, MarkdownToHtmlConverter>();
builder.HealthChecks()
.Add(() => builder.TypeLoader.GetTypes<HealthCheck.HealthCheck>());
.Add(() => builder.TypeLoader.GetTypes<Core.HealthCheck.HealthCheck>());
builder.WithCollectionBuilder<HealthCheckNotificationMethodCollectionBuilder>()
.Add(() => builder.TypeLoader.GetTypes<IHealthCheckNotificationMethod>());
@@ -384,7 +384,10 @@ namespace Umbraco.Core.Runtime
builder.Services.AddUnique<MediaPermissions>();
builder.Services.AddUnique<IImageDimensionExtractor, ImageDimensionExtractor>();
builder.Services.AddUnique<PackageDataInstallation>();
return builder;
}
}
}

View File

@@ -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<UmbracoApplicationStarting>,

View File

@@ -150,6 +150,7 @@ namespace Umbraco.Core.DependencyInjection
builder.Services.AddUnique<IRuntime, CoreRuntime>();
builder.Services.AddHostedService(factory => factory.GetRequiredService<IRuntime>());
builder.AddCoreInitialServices();
builder.AddComposers();
return builder;

View File

@@ -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
/// </summary>
[ComposeBefore(typeof(ICoreComposer))]
[ComposeAfter(typeof(CoreInitialComposer))]
public class AspNetCoreComposer : ComponentComposer<AspNetCoreComponent>, IComposer
{
public override void Compose(IUmbracoBuilder builder)

View File

@@ -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<WebInitialComponent>
{