示例#1
0
        /// <summary>
        /// The initialize.
        /// </summary>
        /// <returns>
        /// The <see cref="IBootManager"/>.
        /// </returns>
        /// <exception cref="InvalidOperationException">
        /// Throws an exception if Merchello is already initialized
        /// </exception>
        public override IBootManager Initialize()
        {
            if (IsInitialized)
            {
                throw new InvalidOperationException("The Merchello core boot manager has already been initialized");
            }

            OnMerchelloInit();

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

            // create the service context for the MerchelloAppContext
            var connString   = ConfigurationManager.ConnectionStrings[MerchelloConfiguration.Current.Section.DefaultConnectionStringName].ConnectionString;
            var providerName = ConfigurationManager.ConnectionStrings[MerchelloConfiguration.Current.Section.DefaultConnectionStringName].ProviderName;

            AutoMapperMappings.CreateMappings();

            _unitOfWorkProvider = new PetaPocoUnitOfWorkProvider(connString, providerName);

            var serviceContext = new ServiceContext(_unitOfWorkProvider);


            var cache = ApplicationContext.Current == null
                            ? new CacheHelper(
                new ObjectCacheRuntimeCacheProvider(),
                new StaticCacheProvider(),
                new NullCacheProvider())
                            : ApplicationContext.Current.ApplicationCache;

            InitializeGatewayResolver(serviceContext, cache);

            CreateMerchelloContext(serviceContext, cache);

            InitializeResolvers();

            InitializeObserverSubscriptions();

            this.InitializeEntityCollectionProviderResolver(MerchelloContext.Current);

            IsInitialized = true;

            return(this);
        }
示例#2
0
        /// <summary>
        /// The initialize.
        /// </summary>
        /// <returns>
        /// The <see cref="IBootManager"/>.
        /// </returns>
        /// <exception cref="InvalidOperationException">
        /// Throws an exception if Merchello is already initialized
        /// </exception>
        public override IBootManager Initialize()
        {
            if (IsInitialized)
            {
                throw new InvalidOperationException("The Merchello core boot manager has already been initialized");
            }

            OnMerchelloInit();

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

            // create the service context for the MerchelloAppContext

            AutoMapperMappings.CreateMappings();

            var serviceContext = new ServiceContext(new RepositoryFactory(_logger, _sqlSyntaxProvider), _unitOfWorkProvider, _logger, new TransientMessageFactory());


            var cache = ApplicationContext.Current == null
                            ? new CacheHelper(
                new ObjectCacheRuntimeCacheProvider(),
                new StaticCacheProvider(),
                new NullCacheProvider())
                            : ApplicationContext.Current.ApplicationCache;

            InitializeGatewayResolver(serviceContext, cache);

            CreateMerchelloContext(serviceContext, cache);

            InitializeResolvers();

            InitializeObserverSubscriptions();

            this.InitializeEntityCollectionProviderResolver(MerchelloContext.Current);

            IsInitialized = true;

            return(this);
        }