示例#1
0
	    public virtual IBootManager Initialize()
		{
			if (_isInitialized)
				throw new InvalidOperationException("The boot manager has already been initialized");

	        InitializeProfilerResolver();

            _timer = DisposableTimer.DebugDuration<CoreBootManager>("Umbraco application starting", "Umbraco application startup complete");

			//create database and service contexts for the app context
			var dbFactory = new DefaultDatabaseFactory(GlobalSettings.UmbracoConnectionName);
		    Database.Mapper = new PetaPocoMapper();
			var dbContext = new DatabaseContext(dbFactory);
			var serviceContext = new ServiceContext(
				new PetaPocoUnitOfWorkProvider(dbFactory), 
				new FileUnitOfWorkProvider(), 
				new PublishingStrategy());

            CreateApplicationContext(dbContext, serviceContext);

            InitializeApplicationEventsResolver();

			InitializeResolvers();

            //initialize the DatabaseContext
            dbContext.Initialize();

            //now we need to call the initialize methods
            ApplicationEventsResolver.Current.ApplicationEventHandlers
                .ForEach(x => x.OnApplicationInitialized(UmbracoApplication, ApplicationContext));

			_isInitialized = true;

			return this;
		}
示例#2
0
 public CommentService(DatabaseContext dbContext, TopicService topicService)
 {
     if (dbContext == null) throw new ArgumentNullException("dbContext");
     if (topicService == null) throw new ArgumentNullException("topicService");
     _databaseContext = dbContext;
     _topicService = topicService;
 }
    	/// <summary>
        /// Constructor
        /// </summary>        
        internal ApplicationContext(DatabaseContext dbContext, ServiceContext serviceContext)
			:this()
    	{
    		if (dbContext == null) throw new ArgumentNullException("dbContext");
    		if (serviceContext == null) throw new ArgumentNullException("serviceContext");

			_databaseContext = dbContext;
			_services = serviceContext;			
    	}
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="dbContext"></param>
 /// <param name="serviceContext"></param>
 /// <param name="cache"></param>
 public ApplicationContext(DatabaseContext dbContext, ServiceContext serviceContext, CacheHelper cache)
 {
     if (dbContext == null) throw new ArgumentNullException("dbContext");
     if (serviceContext == null) throw new ArgumentNullException("serviceContext");
     if (cache == null) throw new ArgumentNullException("cache");
     _databaseContext = dbContext;
     _services = serviceContext;
     ApplicationCache = cache;
 }
		public void Setup()
		{
			_dbContext = new DatabaseContext(new DefaultDatabaseFactory());

			//unfortunately we have to set this up because the PetaPocoExtensions require singleton access
			ApplicationContext.Current = new ApplicationContext(false)
				{
					DatabaseContext = _dbContext,
					IsReady = true
				};			
		}
	    /// <summary>
	    /// A method used to create and ensure that a global ApplicationContext singleton is created.
	    /// </summary>
	    /// <param name="cache"></param>
	    /// <param name="replaceContext">
	    /// If set to true will replace the current singleton instance - This should only be used for unit tests or on app 
	    /// startup if for some reason the boot manager is not the umbraco boot manager.
	    /// </param>
	    /// <param name="dbContext"></param>
	    /// <param name="serviceContext"></param>
	    /// <returns></returns>
	    /// <remarks>
	    /// This is NOT thread safe 
	    /// </remarks>
	    public static ApplicationContext EnsureContext(DatabaseContext dbContext, ServiceContext serviceContext, CacheHelper cache, bool replaceContext)
        {
            if (ApplicationContext.Current != null)
            {
                if (!replaceContext)
                    return ApplicationContext.Current;
            }
            var ctx = new ApplicationContext(dbContext, serviceContext, cache);
            ApplicationContext.Current = ctx;
            return ApplicationContext.Current;
        }
示例#7
0
 public InstallDeliverable(
     TextReader reader,
     TextWriter writer,
     DatabaseContext context,
     IChauffeurSettings settings,
     Func<string, ISqlCeEngine> sqlCeEngineFactory,
     IFileSystem fileSystem
     )
     : base(reader, writer)
 {
     this.context = context;
     this.settings = settings;
     this.sqlCeEngineFactory = sqlCeEngineFactory;
     this.fileSystem = fileSystem;
 }
		public void TearDown()
		{
			_dbContext = null;
			ApplicationContext.Current = null;
		}
示例#9
0
 public ForumService(DatabaseContext dbContext)
 {
     if (dbContext == null) throw new ArgumentNullException("dbContext");
     _databaseContext = dbContext;
 }
示例#10
0
 public TopicService(DatabaseContext dbContext)
 {
     _databaseContext = dbContext;
 }
 public void Init()
 {
     _appContext = ApplicationContext.Current;
     _dbContext = _appContext.DatabaseContext;
     _serviceContext = _appContext.Services;
 }
示例#12
0
 public void Can_Create_Db_Context()
 {
     var dbCtx = new DatabaseContext(new Mock<IDatabaseFactory>().Object);
     Assert.Pass();
 }
 	/// <summary>
     /// Constructor
     /// </summary>        
     internal ApplicationContext(DatabaseContext dbContext, ServiceContext serviceContext)
         : this(dbContext, serviceContext, true)
 	{
 			
 	}
示例#14
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="dbContext"></param>
 /// <param name="serviceContext"></param>
 /// <param name="enableCache"></param>
 public ApplicationContext(DatabaseContext dbContext, ServiceContext serviceContext, bool enableCache)
     : this(enableCache)
 {
     _databaseContext = dbContext;
     _services = serviceContext;		
 }
示例#15
0
 /// <summary>
 /// Creates and assigns the application context singleton
 /// </summary>
 /// <param name="dbContext"></param>
 /// <param name="serviceContext"></param>
 protected virtual void CreateApplicationContext(DatabaseContext dbContext, ServiceContext serviceContext)
 {
     //create the ApplicationContext
     ApplicationContext = ApplicationContext.Current = new ApplicationContext(dbContext, serviceContext);
 }
示例#16
0
 public ContributionService(DatabaseContext dbContext)
 {
     _dbContext = dbContext;
 }
 public VersionCompatibilityService(DatabaseContext databaseContext)
 {
     _databaseContext = databaseContext;
 }
 protected override void CreateApplicationContext(DatabaseContext dbContext, ServiceContext serviceContext)
 {
     base.CreateApplicationContext(dbContext, serviceContext);
 }