Files
Umbraco-CMS/src/Umbraco.Infrastructure/DependencyInjection/UmbracoBuilder.Examine.cs
Mole 9cb1d66b10 V14: Remove Newtonsoft from packed projects (#15811)
* Migrate ObjectJsonExtensions

* Use more generic exception to not use Newtonsoft

It should matter if it's a JsonReaderException, if we can't read we can't read

* Remove obsoleted constructors

* Use more generic exception in ContentValueSetBuilder

* Fix constructors

* Remove UdiRangeJsonConverter

* Remove more legacy newtonsoft stuff

* Migrate away from newtonsoft in CacheInstructionService

* Remove unused model binders

* Remove more newtonsoft

* Remove newtonsoft from DatabaseServerMessenger

* Remove now irrelevant benchmark

* Remove the usage of Newtonsoft from ImageCropperTemplateCoreExtensions

The value converter will never return JObject, JsonDocument, or JsonNode

* Remove usages of newtonsoft in ComplexPropertyEditorContentNotificationHandler

JTokens are no longer returned, so we don't need to check for it

* Remove newtonsoft references

* Re-add newtonsoft dependency to Umbraco.Tests.Common

* Fix package references

* move dependency

---------

Co-authored-by: Bjarke Berg <mail@bergmania.dk>
2024-03-01 12:51:21 +01:00

85 lines
5.1 KiB
C#

using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Umbraco.Cms.Core.DeliveryApi;
using Umbraco.Cms.Core.DependencyInjection;
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Notifications;
using Umbraco.Cms.Core.PropertyEditors;
using Umbraco.Cms.Core.Scoping;
using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Core.Strings;
using Umbraco.Cms.Infrastructure.Examine;
using Umbraco.Cms.Infrastructure.Search;
using Umbraco.Extensions;
namespace Umbraco.Cms.Infrastructure.DependencyInjection;
/// <summary>
/// Provides extension methods to the <see cref="IUmbracoBuilder" /> class.
/// </summary>
public static partial class UmbracoBuilderExtensions
{
public static IUmbracoBuilder AddExamine(this IUmbracoBuilder builder)
{
// populators are not a collection: one cannot remove ours, and can only add more
// the container can inject IEnumerable<IIndexPopulator> and get them all
builder.Services.AddSingleton<IIndexPopulator, MemberIndexPopulator>();
builder.Services.AddSingleton<IIndexPopulator, ContentIndexPopulator>();
builder.Services.AddSingleton<IIndexPopulator, PublishedContentIndexPopulator>();
builder.Services.AddSingleton<IIndexPopulator, MediaIndexPopulator>();
builder.Services.AddSingleton<IIndexPopulator, DeliveryApiContentIndexPopulator>();
builder.Services.AddSingleton<IIndexRebuilder, ExamineIndexRebuilder>();
builder.Services.AddSingleton<IUmbracoIndexingHandler, ExamineUmbracoIndexingHandler>();
builder.Services.AddSingleton<ExamineIndexingMainDomHandler>();
builder.Services.AddUnique<IUmbracoIndexConfig, UmbracoIndexConfig>();
builder.Services.AddUnique<IIndexDiagnosticsFactory, IndexDiagnosticsFactory>();
builder.Services.AddUnique<IPublishedContentValueSetBuilder>(factory =>
new ContentValueSetBuilder(
factory.GetRequiredService<PropertyEditorCollection>(),
factory.GetRequiredService<UrlSegmentProviderCollection>(),
factory.GetRequiredService<IUserService>(),
factory.GetRequiredService<IShortStringHelper>(),
factory.GetRequiredService<IScopeProvider>(),
true,
factory.GetRequiredService<ILocalizationService>(),
factory.GetRequiredService<IContentTypeService>(),
factory.GetRequiredService<ILogger<ContentValueSetBuilder>>()));
builder.Services.AddUnique<IContentValueSetBuilder>(factory =>
new ContentValueSetBuilder(
factory.GetRequiredService<PropertyEditorCollection>(),
factory.GetRequiredService<UrlSegmentProviderCollection>(),
factory.GetRequiredService<IUserService>(),
factory.GetRequiredService<IShortStringHelper>(),
factory.GetRequiredService<IScopeProvider>(),
false,
factory.GetRequiredService<ILocalizationService>(),
factory.GetRequiredService<IContentTypeService>(),
factory.GetRequiredService<ILogger<ContentValueSetBuilder>>()));
builder.Services.AddUnique<IValueSetBuilder<IMedia>, MediaValueSetBuilder>();
builder.Services.AddUnique<IValueSetBuilder<IMember>, MemberValueSetBuilder>();
builder.Services.AddUnique<IDeliveryApiContentIndexValueSetBuilder, DeliveryApiContentIndexValueSetBuilder>();
builder.Services.AddUnique<IDeliveryApiContentIndexFieldDefinitionBuilder, DeliveryApiContentIndexFieldDefinitionBuilder>();
builder.Services.AddUnique<IDeliveryApiContentIndexHelper, DeliveryApiContentIndexHelper>();
builder.Services.AddSingleton<IDeliveryApiIndexingHandler, DeliveryApiIndexingHandler>();
builder.Services.AddSingleton<ExamineIndexRebuilder>(); //TODO remove in Umbraco 15. Only the interface should be in the service provider
builder.Services.AddUnique<IDeliveryApiCompositeIdHandler, DeliveryApiCompositeIdHandler>();
builder.AddNotificationHandler<ContentCacheRefresherNotification, ContentIndexingNotificationHandler>();
builder.AddNotificationHandler<PublicAccessCacheRefresherNotification, ContentIndexingNotificationHandler>();
builder.AddNotificationHandler<ContentTypeCacheRefresherNotification, ContentTypeIndexingNotificationHandler>();
builder.AddNotificationHandler<ContentCacheRefresherNotification, DeliveryApiContentIndexingNotificationHandler>();
builder.AddNotificationHandler<ContentTypeCacheRefresherNotification, DeliveryApiContentIndexingNotificationHandler>();
builder.AddNotificationHandler<PublicAccessCacheRefresherNotification, DeliveryApiContentIndexingNotificationHandler>();
builder.AddNotificationHandler<MediaCacheRefresherNotification, MediaIndexingNotificationHandler>();
builder.AddNotificationHandler<MemberCacheRefresherNotification, MemberIndexingNotificationHandler>();
builder.AddNotificationHandler<LanguageCacheRefresherNotification, LanguageIndexingNotificationHandler>();
builder.AddNotificationHandler<UmbracoRequestBeginNotification, RebuildOnStartupHandler>();
return builder;
}
}