using System; using System.Collections.Generic; using System.Linq; using System.Text; using Umbraco.Core.Logging; using Umbraco.Core.Resolving; namespace Umbraco.Core { /// /// A bootstrapper for the Umbraco application which initializes all objects for the Core of the application /// /// /// This does not provide any startup functionality relating to web objects /// internal class CoreBootManager : IBootManager { private DisposableTimer _timer; public virtual IBootManager Initialize() { LogHelper.Info("Umbraco application starting"); _timer = DisposableTimer.Start(x => LogHelper.Info("Umbraco application startup complete" + " (took " + x + "ms)")); //create the ApplicationContext ApplicationContext.Current = new ApplicationContext() { IsReady = true // fixme }; InitializeResolvers(); return this; } /// /// Fires after initialization and calls the callback to allow for customizations to occur /// /// /// public virtual IBootManager Startup(Action afterStartup) { if (afterStartup != null) { afterStartup(ApplicationContext.Current); } return this; } /// /// Fires after startup and calls the callback once customizations are locked /// /// /// public virtual IBootManager Complete(Action afterComplete) { //freeze resolution to not allow Resolvers to be modified Resolution.Freeze(); //stop the timer and log the output _timer.Dispose(); if (afterComplete != null) { afterComplete(ApplicationContext.Current); } return this; } /// /// Create the resolvers /// protected virtual void InitializeResolvers() { CacheRefreshersResolver.Current = new CacheRefreshersResolver( PluginManager.Current.ResolveCacheRefreshers()); DataTypesResolver.Current = new DataTypesResolver( PluginManager.Current.ResolveDataTypes()); MacroFieldEditorsResolver.Current = new MacroFieldEditorsResolver( PluginManager.Current.ResolveMacroRenderings()); PackageActionsResolver.Current = new PackageActionsResolver( PluginManager.Current.ResolvePackageActions()); } } }