using System; using Microsoft.Extensions.DependencyInjection; using Umbraco.Core.DependencyInjection; using Umbraco.Core.Cache; using Umbraco.Core.Composing; using Umbraco.Core.Dictionary; using Umbraco.Core.IO; using Umbraco.Core.Logging.Viewer; using Umbraco.Core.Manifest; using Umbraco.Core.Models.PublishedContent; using Umbraco.Core.PackageActions; using Umbraco.Core.Persistence.Mappers; using Umbraco.Core.PropertyEditors; using Umbraco.Core.Strings; using Umbraco.Core.Sync; using Umbraco.Web.Media.EmbedProviders; using Umbraco.Web.Search; namespace Umbraco.Core { /// /// Provides extension methods to the class. /// public static partial class CompositionExtensions { #region Collection Builders /// /// Gets the cache refreshers collection builder. /// /// The builder. public static CacheRefresherCollectionBuilder CacheRefreshers(this IUmbracoBuilder builder) => builder.WithCollectionBuilder(); /// /// Gets the mappers collection builder. /// /// The builder. public static MapperCollectionBuilder Mappers(this IUmbracoBuilder builder) => builder.WithCollectionBuilder(); /// /// Gets the package actions collection builder. /// /// The builder. internal static PackageActionCollectionBuilder PackageActions(this IUmbracoBuilder builder) => builder.WithCollectionBuilder(); /// /// Gets the data editor collection builder. /// /// The builder. public static DataEditorCollectionBuilder DataEditors(this IUmbracoBuilder builder) => builder.WithCollectionBuilder(); /// /// Gets the data value reference factory collection builder. /// /// The builder. public static DataValueReferenceFactoryCollectionBuilder DataValueReferenceFactories(this IUmbracoBuilder builder) => builder.WithCollectionBuilder(); /// /// Gets the property value converters collection builder. /// /// The builder. public static PropertyValueConverterCollectionBuilder PropertyValueConverters(this IUmbracoBuilder builder) => builder.WithCollectionBuilder(); /// /// Gets the url segment providers collection builder. /// /// The builder. public static UrlSegmentProviderCollectionBuilder UrlSegmentProviders(this IUmbracoBuilder builder) => builder.WithCollectionBuilder(); /// /// Gets the validators collection builder. /// /// The builder. internal static ManifestValueValidatorCollectionBuilder ManifestValueValidators(this IUmbracoBuilder builder) => builder.WithCollectionBuilder(); /// /// Gets the manifest filter collection builder. /// /// The builder. public static ManifestFilterCollectionBuilder ManifestFilters(this IUmbracoBuilder builder) => builder.WithCollectionBuilder(); /// /// Gets the backoffice OEmbed Providers collection builder. /// /// The builder. public static EmbedProvidersCollectionBuilder OEmbedProviders(this IUmbracoBuilder builder) => builder.WithCollectionBuilder(); /// /// Gets the back office searchable tree collection builder /// /// /// public static SearchableTreeCollectionBuilder SearchableTrees(this IUmbracoBuilder builder) => builder.WithCollectionBuilder(); #endregion #region Uniques /// /// Sets the culture dictionary factory. /// /// The type of the factory. /// The builder. public static void SetCultureDictionaryFactory(this IUmbracoBuilder builder) where T : class, ICultureDictionaryFactory { builder.Services.AddUnique(); } /// /// Sets the culture dictionary factory. /// /// The builder. /// A function creating a culture dictionary factory. public static void SetCultureDictionaryFactory(this IUmbracoBuilder builder, Func factory) { builder.Services.AddUnique(factory); } /// /// Sets the culture dictionary factory. /// /// The builder. /// A factory. public static void SetCultureDictionaryFactory(this IUmbracoBuilder builder, ICultureDictionaryFactory factory) { builder.Services.AddUnique(factory); } /// /// Sets the published content model factory. /// /// The type of the factory. /// The builder. public static void SetPublishedContentModelFactory(this IUmbracoBuilder builder) where T : class, IPublishedModelFactory { builder.Services.AddUnique(); } /// /// Sets the published content model factory. /// /// The builder. /// A function creating a published content model factory. public static void SetPublishedContentModelFactory(this IUmbracoBuilder builder, Func factory) { builder.Services.AddUnique(factory); } /// /// Sets the published content model factory. /// /// The builder. /// A published content model factory. public static void SetPublishedContentModelFactory(this IUmbracoBuilder builder, IPublishedModelFactory factory) { builder.Services.AddUnique(factory); } /// /// Sets the server registrar. /// /// The type of the server registrar. /// The builder. public static void SetServerRegistrar(this IUmbracoBuilder builder) where T : class, IServerRegistrar { builder.Services.AddUnique(); } /// /// Sets the server registrar. /// /// The builder. /// A function creating a server registrar. public static void SetServerRegistrar(this IUmbracoBuilder builder, Func factory) { builder.Services.AddUnique(factory); } /// /// Sets the server registrar. /// /// The builder. /// A server registrar. public static void SetServerRegistrar(this IUmbracoBuilder builder, IServerRegistrar registrar) { builder.Services.AddUnique(registrar); } /// /// Sets the server messenger. /// /// The type of the server registrar. /// The builder. public static void SetServerMessenger(this IUmbracoBuilder builder) where T : class, IServerMessenger { builder.Services.AddUnique(); } /// /// Sets the server messenger. /// /// The builder. /// A function creating a server messenger. public static void SetServerMessenger(this IUmbracoBuilder builder, Func factory) { builder.Services.AddUnique(factory); } /// /// Sets the server messenger. /// /// The builder. /// A server messenger. public static void SetServerMessenger(this IUmbracoBuilder builder, IServerMessenger registrar) { builder.Services.AddUnique(registrar); } /// /// Sets the database server messenger options. /// /// The builder. /// A function creating the options. /// Use DatabaseServerRegistrarAndMessengerComposer.GetDefaultOptions to get the options that Umbraco would use by default. public static void SetDatabaseServerMessengerCallbacks(this IUmbracoBuilder builder, Func factory) { builder.Services.AddUnique(factory); } /// /// Sets the database server messenger options. /// /// The builder. /// Options. /// Use DatabaseServerRegistrarAndMessengerComposer.GetDefaultOptions to get the options that Umbraco would use by default. public static void SetDatabaseServerMessengerOptions(this IUmbracoBuilder builder, DatabaseServerMessengerCallbacks options) { builder.Services.AddUnique(options); } /// /// Sets the short string helper. /// /// The type of the short string helper. /// The builder. public static void SetShortStringHelper(this IUmbracoBuilder builder) where T : class, IShortStringHelper { builder.Services.AddUnique(); } /// /// Sets the short string helper. /// /// The builder. /// A function creating a short string helper. public static void SetShortStringHelper(this IUmbracoBuilder builder, Func factory) { builder.Services.AddUnique(factory); } /// /// Sets the short string helper. /// /// A builder. /// A short string helper. public static void SetShortStringHelper(this IUmbracoBuilder builder, IShortStringHelper helper) { builder.Services.AddUnique(helper); } /// /// Sets the underlying media filesystem. /// /// A builder. /// A filesystem factory. /// /// Using this helper will ensure that your IFileSystem implementation is wrapped by the ShadowWrapper /// public static void SetMediaFileSystem(this IUmbracoBuilder builder, Func filesystemFactory) => builder.Services.AddUnique(factory => { var fileSystems = factory.GetRequiredService(); return fileSystems.GetFileSystem(filesystemFactory(factory)); }); /// /// Sets the log viewer. /// /// The type of the log viewer. /// The builder. public static void SetLogViewer(this IUmbracoBuilder builder) where T : class, ILogViewer { builder.Services.AddUnique(); } /// /// Sets the log viewer. /// /// The builder. /// A function creating a log viewer. public static void SetLogViewer(this IUmbracoBuilder builder, Func factory) { builder.Services.AddUnique(factory); } /// /// Sets the log viewer. /// /// A builder. /// A log viewer. public static void SetLogViewer(this IUmbracoBuilder builder, ILogViewer viewer) { builder.Services.AddUnique(viewer); } #endregion } }