當前位置: 首頁>>代碼示例>>C#>>正文


C# Core.ApplicationContext類代碼示例

本文整理匯總了C#中Umbraco.Core.ApplicationContext的典型用法代碼示例。如果您正苦於以下問題:C# ApplicationContext類的具體用法?C# ApplicationContext怎麽用?C# ApplicationContext使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ApplicationContext類屬於Umbraco.Core命名空間,在下文中一共展示了ApplicationContext類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: ApplicationStarted

        protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
        {
            base.ApplicationStarted(umbracoApplication, applicationContext);

            InvoiceService.StatusChanging += InvoiceService_StatusChanging;
            InvoiceService.StatusChanged += InvoiceService_StatusChanged;
        }
開發者ID:rustyswayne,項目名稱:Merchello,代碼行數:7,代碼來源:InvoiceStatusChangeCheck.cs

示例2: OnApplicationInitialized

 public void OnApplicationInitialized(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
 {
     DocumentTypeStrategyFactory.Current.SetStrategy(null);
     DocumentTypeStrategyFactory.Current.Execute();
     // something.Execute();
     // uCodeIt.Strategies.DoctypeStrategyFactory.Current.Execute();
 }
開發者ID:revolution42,項目名稱:uCodeIt,代碼行數:7,代碼來源:StartupHandler.cs

示例3: ApplicationStarted

        /// <summary>
        /// See https://our.umbraco.org/documentation/Reference/Events/ for event handling documentation.
        /// </summary>
        /// <param name="umbracoApplication"></param>
        /// <param name="applicationContext"></param>
        protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
        {
            queueConnection = new SqlConnection(applicationContext.DatabaseContext.ConnectionString);

            /*
            ContentService
            MediaService
            ContentTypeService
            MemberService
            FileService
            LocalizationService
            DataTypeService
            */

            var contentQueue = new ContentQueue(queueConnection);
            ContentService.Saved += contentQueue.ContentService_Saved;

            var mediaQueue = new MediaQueue(queueConnection);
            MediaService.Saved += mediaQueue.MediaService_Saved;
            MediaService.Deleted += mediaQueue.MediaService_Deleted;

            var memberQueue = new MemberQueue(queueConnection);
            MemberService.Created += memberQueue.MemberService_Created;

            base.ApplicationStarted(umbracoApplication, applicationContext);
        }
開發者ID:JamesGreenAU,項目名稱:UmbracoServiceBroker,代碼行數:31,代碼來源:ServiceBrokerAppEventHandler.cs

示例4: ApplicationStarted

        protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
        {
            base.ApplicationStarted(umbracoApplication, applicationContext);

            LogHelper.Info<ExamineEvents>("Initializing Merchello ProductIndex binding events");

            // Merchello registered providers
            var registeredProviders =
                ExamineManager.Instance.IndexProviderCollection.OfType<BaseMerchelloIndexer>()
                    .Count(x => x.EnableDefaultEventHandler);

            if(registeredProviders == 0)
                return;

            ProductService.Created += ProductServiceCreated;
            ProductService.Saved += ProductServiceSaved;
            ProductService.Deleted += ProductServiceDeleted;

            ProductVariantService.Created += ProductVariantServiceCreated;
            ProductVariantService.Saved += ProductVariantServiceSaved;
            ProductVariantService.Deleted += ProductVariantServiceDeleted;

            InvoiceService.Saved += InvoiceServiceSaved;
            InvoiceService.Deleted += InvoiceServiceDeleted;

            OrderService.Saved += OrderServiceSaved;
            OrderService.Deleted += OrderServiceDeleted;
        }
開發者ID:VDBBjorn,項目名稱:Merchello,代碼行數:28,代碼來源:ExamineEvents.cs

示例5: EnsureContext

        /// <summary>
        /// This is a helper method which is called to ensure that the singleton context is created and the nice url and routing
        /// context is created and assigned.
        /// </summary>
        /// <param name="httpContext"></param>
        /// <param name="applicationContext"></param>
        /// <param name="replaceContext">
        /// if set to true will replace the current singleton with a new one, this is generally only ever used because
        /// during application startup the base url domain will not be available so after app startup we'll replace the current
        /// context with a new one in which we can access the httpcontext.Request object.
        /// </param>
        /// <returns>
        /// The Singleton context object
        /// </returns>
        /// <remarks>
        /// This is created in order to standardize the creation of the singleton. Normally it is created during a request
        /// in the UmbracoModule, however this module does not execute during application startup so we need to ensure it
        /// during the startup process as well.
        /// See: http://issues.umbraco.org/issue/U4-1890, http://issues.umbraco.org/issue/U4-1717
        /// </remarks>
        public static UmbracoContext EnsureContext(HttpContextBase httpContext, ApplicationContext applicationContext, bool replaceContext, bool? preview)
        {
            if (UmbracoContext.Current != null)
            {
                if (!replaceContext)
                    return UmbracoContext.Current;
                UmbracoContext.Current._replacing = true;
            }

            var umbracoContext = new UmbracoContext(
                httpContext,
                applicationContext,
                PublishedCachesResolver.Current.Caches,
                preview);

            // create the nice urls provider
            // there's one per request because there are some behavior parameters that can be changed
            var urlProvider = new UrlProvider(
                umbracoContext,
                UrlProviderResolver.Current.Providers);

            // create the RoutingContext, and assign
            var routingContext = new RoutingContext(
                umbracoContext,
                ContentFinderResolver.Current.Finders,
                ContentLastChanceFinderResolver.Current.Finder,
                urlProvider);

            //assign the routing context back
            umbracoContext.RoutingContext = routingContext;

            //assign the singleton
            UmbracoContext.Current = umbracoContext;
            return UmbracoContext.Current;
        }
開發者ID:saciervo,項目名稱:Umbraco-CMS,代碼行數:55,代碼來源:UmbracoContext.cs

示例6: OnApplicationStarting

        public void OnApplicationStarting(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
        {
            var treeService = ApplicationContext.Current.Services.ApplicationTreeService;

            // Hide default Umbraco Forms folder, we use our own to display folders
            var umbFormTree = treeService.GetByAlias("form");
            if (umbFormTree != null && umbFormTree.Initialize)
            {
                umbFormTree.Initialize = false;
                treeService.SaveTree(umbFormTree);
            }

            // Add our own tree if it's not there yet
            var pplxFormTree = treeService.GetByAlias("perplexForms");
            if (pplxFormTree == null)
            {
                treeService.MakeNew(true, 1, "forms", "perplexForms", "Forms", "icon-folder", "icon-folder-open", "PerplexUmbraco.Forms.Controllers.PerplexFormTreeController, Perplex.Umbraco.Forms");
            }

            FormStorage.Created += FormStorage_Created;
            FormStorage.Deleted += FormStorage_Deleted;

            // Create perplexUmbracoUser for storage of Forms start nodes
            // if it does not exist already. There seem to be some issues with SqlServer CE,
            // it does not support some statements in this query.
            // Those will be fixed later, for now we continue
            try { Sql.ExecuteSql(PerplexUmbraco.Forms.Code.Constants.SQL_CREATE_PERPLEX_USER_TABLE_IF_NOT_EXISTS); }
            catch (Exception) { }
        }
開發者ID:PerplexInternetmarketing,項目名稱:Perplex-Umbraco-Forms,代碼行數:29,代碼來源:MvcApplication.cs

示例7: OnApplicationStarted

        public void OnApplicationStarted(UmbracoApplicationBase httpApplication, ApplicationContext applicationContext)
        {
            this.httpApplication = httpApplication;
            this.applicationContext = applicationContext;

            umbraco.content.AfterRefreshContent += new umbraco.content.RefreshContentEventHandler(content_AfterRefreshContent);
        }
開發者ID:pdebacker,項目名稱:UmbCodeGen_Example_Project_Razor,代碼行數:7,代碼來源:TypeLibBuilder.cs

示例8: EnsureContext

        /// <summary>
        /// This is a helper method which is called to ensure that the singleton context is created and the nice url and routing
        /// context is created and assigned.
        /// </summary>
        /// <param name="httpContext"></param>
        /// <param name="applicationContext"></param>
        /// <param name="replaceContext">
        /// if set to true will replace the current singleton with a new one, this is generally only ever used because
        /// during application startup the base url domain will not be available so after app startup we'll replace the current
        /// context with a new one in which we can access the httpcontext.Request object.
        /// </param>
        /// <returns>
        /// The Singleton context object
        /// </returns>
        /// <remarks>
        /// This is created in order to standardize the creation of the singleton. Normally it is created during a request
        /// in the UmbracoModule, however this module does not execute during application startup so we need to ensure it
        /// during the startup process as well.
        /// See: http://issues.umbraco.org/issue/U4-1890
        /// </remarks>
        internal static UmbracoContext EnsureContext(HttpContextBase httpContext, ApplicationContext applicationContext, bool replaceContext)
        {
            if (UmbracoContext.Current != null)
            {
                if (!replaceContext)
                    return UmbracoContext.Current;
                UmbracoContext.Current._replacing = true;
            }

            var umbracoContext = new UmbracoContext(httpContext, applicationContext, RoutesCacheResolver.Current.RoutesCache);

            // create the nice urls provider
            var niceUrls = new NiceUrlProvider(PublishedContentStoreResolver.Current.PublishedContentStore, umbracoContext);

            // create the RoutingContext, and assign
            var routingContext = new RoutingContext(
                umbracoContext,
                DocumentLookupsResolver.Current.DocumentLookups,
                LastChanceLookupResolver.Current.LastChanceLookup,
                PublishedContentStoreResolver.Current.PublishedContentStore,
                niceUrls);

            //assign the routing context back
            umbracoContext.RoutingContext = routingContext;

            //assign the singleton
            UmbracoContext.Current = umbracoContext;
            return UmbracoContext.Current;
        }
開發者ID:phaniarveti,項目名稱:Experiments,代碼行數:49,代碼來源:UmbracoContext.cs

示例9: ApplicationStarted

 protected override void ApplicationStarted(
     UmbracoApplicationBase umbracoApplication,
     ApplicationContext applicationContext)
 {
     base.ApplicationStarted(umbracoApplication,applicationContext);
     BundleConfig.RegisterBundles(BundleTable.Bundles);
 }
開發者ID:kjasiewicz,項目名稱:Reset-Umbraco,代碼行數:7,代碼來源:CustomStartupHandler.cs

示例10: OnApplicationStarted

        public void OnApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
        {
            // Map the Custom routes
            DialogueRoutes.MapRoutes(RouteTable.Routes, UmbracoContext.Current.ContentCache);

            //list to the init event of the application base, this allows us to bind to the actual HttpApplication events
            UmbracoApplicationBase.ApplicationInit += UmbracoApplicationBase_ApplicationInit;

            MemberService.Saved += MemberServiceSaved;
            MemberService.Deleting += MemberServiceOnDeleting;
            ContentService.Trashing +=ContentService_Trashing;

            PageCacheRefresher.CacheUpdated += PageCacheRefresher_CacheUpdated;

            // Sync the badges
            // Do the badge processing
            var unitOfWorkManager = new UnitOfWorkManager(ContextPerRequest.Db);
            using (var unitOfWork = unitOfWorkManager.NewUnitOfWork())
            {
                try
                {
                    ServiceFactory.BadgeService.SyncBadges();
                    unitOfWork.Commit();
                }
                catch (Exception ex)
                {
                    AppHelpers.LogError(string.Format("Error processing badge classes: {0}", ex.Message));
                }
            }

        }
開發者ID:ryan-buckman,項目名稱:Dialogue,代碼行數:31,代碼來源:UmbracoEvents.cs

示例11: ExecuteMigrations

        private static void ExecuteMigrations(ApplicationContext applicationContext, Dictionary<string, IMigration> migrations)
        {
            var db = applicationContext.DatabaseContext.Database;
            var databaseMigrations = db.Query<DbMigration>("SELECT * FROM Lucrasoft_Migrations")
                                       .Select(x => x.MigrationName)
                                       .ToList();

            foreach (var migration in migrations)
            {
                if (databaseMigrations.Contains(migration.Key, CaseInsensitiveStringComparer.Instance))
                {
                    LogHelper.Debug<Migrator>(string.Format("Lucrasoft uMigrations (version {0}) - Skipping migration '{1}' because it has already been executed", Version, migration.Key));
                    continue;
                }

                try
                {
                    LogHelper.Info<Migrator>(string.Format("Lucrasoft uMigrations (version {0}) - Running migration with key '{1}'", Version, migration.Key));
                    migration.Value.MigrationAction.Invoke(applicationContext);
                }
                catch (Exception ex)
                {
                    LogHelper.Error<Migrator>(string.Format("Lucrasoft uMigrations (version {0}) - Migration '{1}' failed: {2}", Version, migration.Key, ex.Message), ex);
                    throw;
                }

                db.Insert(new DbMigration
                {
                    MigrationDateTime = DateTime.Now,
                    MigrationName = migration.Key
                });

                databaseMigrations.Add(migration.Key);
            }
        }
開發者ID:Lucrasoft,項目名稱:uMigrations,代碼行數:35,代碼來源:Migrator.cs

示例12: UseUmbracoCookieAuthenticationForRestApi

        /// <summary>
        /// Used to enable back office cookie authentication for the REST API calls
        /// </summary>
        /// <param name="app"></param>
        /// <param name="appContext"></param>
        /// <returns></returns>
        public static IAppBuilder UseUmbracoCookieAuthenticationForRestApi(this IAppBuilder app, ApplicationContext appContext)
        {
            //Don't proceed if the app is not ready
            if (appContext.IsUpgrading == false && appContext.IsConfigured == false) return app;

            var authOptions = new UmbracoBackOfficeCookieAuthOptions(
                UmbracoConfig.For.UmbracoSettings().Security,
                GlobalSettings.TimeOutInMinutes,
                GlobalSettings.UseSSL)
            {
                Provider = new BackOfficeCookieAuthenticationProvider
                {
                    // Enables the application to validate the security stamp when the user
                    // logs in. This is a security feature which is used when you
                    // change a password or add an external login to your account.
                    OnValidateIdentity = SecurityStampValidator
                        .OnValidateIdentity<BackOfficeUserManager, BackOfficeIdentityUser, int>(
                            TimeSpan.FromMinutes(30),
                            (manager, user) => user.GenerateUserIdentityAsync(manager),
                            identity => identity.GetUserId<int>()),
                }
            };

            //This is what will ensure that the rest api calls are auth'd
            authOptions.CookieManager = new RestApiCookieManager();

            app.UseCookieAuthentication(authOptions);

            return app;
        }
開發者ID:robertjf,項目名稱:UmbracoRestApi,代碼行數:36,代碼來源:AppBuilderExtensions.cs

示例13: OnApplicationStarting

		public void OnApplicationStarting(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
		{
			if (InternalHelpers.MvcRenderMode)
			{
				ContentFinderResolver.Current.InsertTypeBefore<ContentFinderByPageIdQuery, CatalogContentFinder>();
			}
		}
開發者ID:Chuhukon,項目名稱:uWebshop-Releases,代碼行數:7,代碼來源:CatalogContentFinder.cs

示例14: ApplicationStarted

        protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication,
            ApplicationContext applicationContext)
        {
            AddPluginSectionToDevelopersDashboard();

            ContentService.Published += ContentService_Published;
        }
開發者ID:mzajkowski,項目名稱:UmbracoCloudFlareManager,代碼行數:7,代碼來源:UmbracoStartupHandler.cs

示例15: Initialize

        public override void Initialize()
        {
            InitializeFirstRunFlags();
            
            var path = TestHelper.CurrentAssemblyDirectory;
            AppDomain.CurrentDomain.SetData("DataDirectory", path);

            var dbFactory = new DefaultDatabaseFactory(
                GetDbConnectionString(),
                GetDbProviderName());
            _appContext = new ApplicationContext(
				//assign the db context
                new DatabaseContext(dbFactory),
				//assign the service context
                new ServiceContext(new PetaPocoUnitOfWorkProvider(dbFactory), new FileUnitOfWorkProvider(), new PublishingStrategy()),
                //disable cache
                false)
                {
                    IsReady = true
                };

            base.Initialize();

            DatabaseContext.Initialize(dbFactory.ProviderName, dbFactory.ConnectionString);

            CreateSqlCeDatabase();

            InitializeDatabase();

            //ensure the configuration matches the current version for tests
            SettingsForTests.ConfigurationStatus = UmbracoVersion.Current.ToString(3);
        }
開發者ID:Baud-spol-s-r-o,項目名稱:BaudUmbraco,代碼行數:32,代碼來源:BaseDatabaseFactoryTest.cs


注:本文中的Umbraco.Core.ApplicationContext類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。