当前位置: 首页>>代码示例>>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;未经允许,请勿转载。