using System; 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; namespace Umbraco.Core { /// /// Provides extension methods to the class. /// public static partial class CompositionExtensions { #region Collection Builders /// /// Gets the cache refreshers collection builder. /// /// The composition. public static CacheRefresherCollectionBuilder CacheRefreshers(this Composition composition) => composition.WithCollectionBuilder(); /// /// Gets the mappers collection builder. /// /// The composition. public static MapperCollectionBuilder Mappers(this Composition composition) => composition.WithCollectionBuilder(); /// /// Gets the package actions collection builder. /// /// The composition. internal static PackageActionCollectionBuilder PackageActions(this Composition composition) => composition.WithCollectionBuilder(); /// /// Gets the data editor collection builder. /// /// The composition. public static DataEditorCollectionBuilder DataEditors(this Composition composition) => composition.WithCollectionBuilder(); /// /// Gets the data value reference factory collection builder. /// /// The composition. public static DataValueReferenceFactoryCollectionBuilder DataValueReferenceFactories(this Composition composition) => composition.WithCollectionBuilder(); /// /// Gets the property value converters collection builder. /// /// The composition. public static PropertyValueConverterCollectionBuilder PropertyValueConverters(this Composition composition) => composition.WithCollectionBuilder(); /// /// Gets the url segment providers collection builder. /// /// The composition. public static UrlSegmentProviderCollectionBuilder UrlSegmentProviders(this Composition composition) => composition.WithCollectionBuilder(); /// /// Gets the validators collection builder. /// /// The composition. internal static ManifestValueValidatorCollectionBuilder ManifestValueValidators(this Composition composition) => composition.WithCollectionBuilder(); /// /// Gets the manifest filter collection builder. /// /// The composition. public static ManifestFilterCollectionBuilder ManifestFilters(this Composition composition) => composition.WithCollectionBuilder(); /// /// Gets the components collection builder. /// public static ComponentCollectionBuilder Components(this Composition composition) => composition.WithCollectionBuilder(); #endregion #region Uniques /// /// Sets the culture dictionary factory. /// /// The type of the factory. /// The composition. public static void SetCultureDictionaryFactory(this Composition composition) where T : ICultureDictionaryFactory { composition.RegisterUnique(); } /// /// Sets the culture dictionary factory. /// /// The composition. /// A function creating a culture dictionary factory. public static void SetCultureDictionaryFactory(this Composition composition, Func factory) { composition.RegisterUnique(factory); } /// /// Sets the culture dictionary factory. /// /// The composition. /// A factory. public static void SetCultureDictionaryFactory(this Composition composition, ICultureDictionaryFactory factory) { composition.RegisterUnique(_ => factory); } /// /// Sets the published content model factory. /// /// The type of the factory. /// The composition. public static void SetPublishedContentModelFactory(this Composition composition) where T : IPublishedModelFactory { composition.RegisterUnique(); } /// /// Sets the published content model factory. /// /// The composition. /// A function creating a published content model factory. public static void SetPublishedContentModelFactory(this Composition composition, Func factory) { composition.RegisterUnique(factory); } /// /// Sets the published content model factory. /// /// The composition. /// A published content model factory. public static void SetPublishedContentModelFactory(this Composition composition, IPublishedModelFactory factory) { composition.RegisterUnique(_ => factory); } /// /// Sets the server registrar. /// /// The type of the server registrar. /// The composition. public static void SetServerRegistrar(this Composition composition) where T : IServerRegistrar { composition.RegisterUnique(); } /// /// Sets the server registrar. /// /// The composition. /// A function creating a server registrar. public static void SetServerRegistrar(this Composition composition, Func factory) { composition.RegisterUnique(factory); } /// /// Sets the server registrar. /// /// The composition. /// A server registrar. public static void SetServerRegistrar(this Composition composition, IServerRegistrar registrar) { composition.RegisterUnique(_ => registrar); } /// /// Sets the server messenger. /// /// The type of the server registrar. /// The composition. public static void SetServerMessenger(this Composition composition) where T : IServerMessenger { composition.RegisterUnique(); } /// /// Sets the server messenger. /// /// The composition. /// A function creating a server messenger. public static void SetServerMessenger(this Composition composition, Func factory) { composition.RegisterUnique(factory); } /// /// Sets the server messenger. /// /// The composition. /// A server messenger. public static void SetServerMessenger(this Composition composition, IServerMessenger registrar) { composition.RegisterUnique(_ => registrar); } /// /// Sets the database server messenger options. /// /// The composition. /// A function creating the options. /// Use DatabaseServerRegistrarAndMessengerComposer.GetDefaultOptions to get the options that Umbraco would use by default. public static void SetDatabaseServerMessengerOptions(this Composition composition, Func factory) { composition.RegisterUnique(factory); } /// /// Sets the database server messenger options. /// /// The composition. /// Options. /// Use DatabaseServerRegistrarAndMessengerComposer.GetDefaultOptions to get the options that Umbraco would use by default. public static void SetDatabaseServerMessengerOptions(this Composition composition, DatabaseServerMessengerOptions options) { composition.RegisterUnique(_ => options); } /// /// Sets the short string helper. /// /// The type of the short string helper. /// The composition. public static void SetShortStringHelper(this Composition composition) where T : IShortStringHelper { composition.RegisterUnique(); } /// /// Sets the short string helper. /// /// The composition. /// A function creating a short string helper. public static void SetShortStringHelper(this Composition composition, Func factory) { composition.RegisterUnique(factory); } /// /// Sets the short string helper. /// /// A composition. /// A short string helper. public static void SetShortStringHelper(this Composition composition, IShortStringHelper helper) { composition.RegisterUnique(_ => helper); } /// /// Sets the underlying media filesystem. /// /// A composition. /// A filesystem factory. public static void SetMediaFileSystem(this Composition composition, Func filesystemFactory) => composition.RegisterUniqueFor(filesystemFactory); /// /// Sets the underlying media filesystem. /// /// A composition. /// A filesystem factory. public static void SetMediaFileSystem(this Composition composition, Func filesystemFactory) => composition.RegisterUniqueFor(_ => filesystemFactory()); /// /// Sets the log viewer. /// /// The type of the log viewer. /// The composition. public static void SetLogViewer(this Composition composition) where T : ILogViewer { composition.RegisterUnique(); } /// /// Sets the log viewer. /// /// The composition. /// A function creating a log viewer. public static void SetLogViewer(this Composition composition, Func factory) { composition.RegisterUnique(factory); } /// /// Sets the log viewer. /// /// A composition. /// A log viewer. public static void SetLogViewer(this Composition composition, ILogViewer viewer) { composition.RegisterUnique(_ => viewer); } #endregion } }