예제 #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;
 }
예제 #3
0
    	/// <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;			
    	}
예제 #4
0
 /// <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
				};			
		}
예제 #6
0
	    /// <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;
 }
예제 #11
0
 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();
 }
예제 #13
0
 	/// <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);
 }