using System; using Umbraco.Core.Cache; using Umbraco.Core.Composing; using Umbraco.Core.Composing.CompositionExtensions; using Umbraco.Core.Configuration; using Umbraco.Core.Configuration.UmbracoSettings; using Umbraco.Core.Dashboards; using Umbraco.Core.Hosting; using Umbraco.Core.Dictionary; using Umbraco.Core.Logging; using Umbraco.Core.Manifest; using Umbraco.Core.Migrations; using Umbraco.Core.Migrations.Install; using Umbraco.Core.Migrations.PostMigrations; using Umbraco.Core.Models.PublishedContent; using Umbraco.Core.Persistence; using Umbraco.Core.PropertyEditors; using Umbraco.Core.PropertyEditors.Validators; using Umbraco.Core.Scoping; using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; using Umbraco.Core.Sync; using Umbraco.Web.Models.PublishedContent; using Umbraco.Web.PublishedCache; using Umbraco.Web; using Umbraco.Web.Services; using IntegerValidator = Umbraco.Core.PropertyEditors.Validators.IntegerValidator; namespace Umbraco.Core.Runtime { // core's initial composer composes before all core composers [ComposeBefore(typeof(ICoreComposer))] public class CoreInitialComposer : ComponentComposer { public override void Compose(Composition composition) { base.Compose(composition); // composers composition .ComposeConfiguration() .ComposeRepositories() .ComposeServices() .ComposeCoreMappingProfiles() .ComposeFileSystems(); // register persistence mappers - required by database factory so needs to be done here // means the only place the collection can be modified is in a runtime - afterwards it // has been frozen and it is too late composition.Mappers().AddCoreMappers(); // register the scope provider composition.RegisterUnique(); // implements both IScopeProvider and IScopeAccessor composition.RegisterUnique(f => f.GetInstance()); composition.RegisterUnique(f => f.GetInstance()); composition.RegisterUnique(); // register database builder // *not* a singleton, don't want to keep it around composition.Register(); // register manifest parser, will be injected in collection builders where needed composition.RegisterUnique(); // register our predefined validators composition.ManifestValueValidators() .Add() .Add() .Add() .Add() .Add() .Add(); // register the manifest filter collection builder (collection is empty by default) composition.ManifestFilters(); // properties and parameters derive from data editors composition.DataEditors() .Add(() => composition.TypeLoader.GetDataEditors()); composition.RegisterUnique(); composition.RegisterUnique(); // Used to determine if a datatype/editor should be storing/tracking // references to media item/s composition.DataValueReferenceFactories(); // register a server registrar, by default it's the db registrar composition.RegisterUnique(f => { var globalSettings = f.GetInstance(); // TODO: we still register the full IServerMessenger because // even on 1 single server we can have 2 concurrent app domains var singleServer = globalSettings.DisableElectionForSingleServer; return singleServer ? (IServerRegistrar) new SingleServerRegistrar(f.GetInstance()) : new DatabaseServerRegistrar( new Lazy(f.GetInstance), new DatabaseServerRegistrarOptions()); }); // by default we'll use the database server messenger with default options (no callbacks), // this will be overridden by the db thing in the corresponding components in the web // project composition.RegisterUnique(factory => new DatabaseServerMessenger( factory.GetInstance(), factory.GetInstance(), factory.GetInstance(), factory.GetInstance(), true, new DatabaseServerMessengerOptions(), factory.GetInstance(), factory.GetInstance() )); composition.CacheRefreshers() .Add(() => composition.TypeLoader.GetCacheRefreshers()); composition.PackageActions() .Add(() => composition.TypeLoader.GetPackageActions()); composition.PropertyValueConverters() .Append(composition.TypeLoader.GetTypes()); composition.RegisterUnique(); composition.RegisterUnique(factory => new DefaultShortStringHelper(new DefaultShortStringHelperConfig().WithDefault(factory.GetInstance()))); composition.UrlSegmentProviders() .Append(); composition.RegisterUnique(factory => new MigrationBuilder(factory)); // by default, register a noop factory composition.RegisterUnique(); // by default, register a noop rebuilder composition.RegisterUnique(); composition.SetCultureDictionaryFactory(); composition.Register(f => f.GetInstance().CreateDictionary(), Lifetime.Singleton); composition.RegisterUnique(); // register the published snapshot accessor - the "current" published snapshot is in the umbraco context composition.RegisterUnique(); composition.RegisterUnique(); composition.RegisterUnique(); // register core CMS dashboards and 3rd party types - will be ordered by weight attribute & merged with package.manifest dashboards composition.Dashboards() .Add(composition.TypeLoader.GetTypes()); } } }