Пример #1
0
        /// <summary>
        /// Determines if the view should be found, this is used for view lookup performance and also to ensure
        /// less overlap with other user's view engines. This will return true if the Umbraco back office is rendering
        /// and its a partial view or if the umbraco front-end is rendering but nothing else.
        /// </summary>
        /// <param name="controllerContext"></param>
        /// <param name="isPartial"></param>
        /// <returns></returns>
        private static bool ShouldFindView(ControllerContext controllerContext, bool isPartial)
        {
            var umbracoToken = controllerContext.GetDataTokenInViewContextHierarchy(Core.Constants.Web.UmbracoDataToken);

            // first check if we're rendering a partial view for the back office, or surface controller, etc...
            // anything that is not ContentModel as this should only pertain to Umbraco views.
            if (isPartial && !(umbracoToken is ContentModel))
            {
                return(true);
            }

            // only find views if we're rendering the umbraco front end
            return(umbracoToken is ContentModel);
        }
Пример #2
0
        /// <summary>
        /// Determines if the view should be found, this is used for view lookup performance and also to ensure
        /// less overlap with other user's view engines. This will return true if the Umbraco back office is rendering
        /// and its a partial view or if the umbraco front-end is rendering but nothing else.
        /// </summary>
        /// <param name="controllerContext"></param>
        /// <param name="isPartial"></param>
        /// <returns></returns>
        private bool ShouldFindView(ControllerContext controllerContext, bool isPartial)
        {
            var umbracoToken = controllerContext.GetDataTokenInViewContextHierarchy("umbraco");

            //first check if we're rendering a partial view for the back office, or surface controller, etc...
            //anything that is not IUmbracoRenderModel as this should only pertain to Umbraco views.
            if (isPartial && ((umbracoToken is RenderModel) == false))
            {
                return(true);
            }

            //only find views if we're rendering the umbraco front end
            if (umbracoToken is RenderModel)
            {
                return(true);
            }

            return(false);
        }
Пример #3
0
        /// <summary>
        /// Gets the Umbraco context from a controller context hierarchy, if any, else the 'current' Umbraco context.
        /// </summary>
        /// <param name="controllerContext">The controller context.</param>
        /// <returns>The Umbraco context.</returns>
        public static UmbracoContext GetUmbracoContext(this ControllerContext controllerContext)
        {
            var o = controllerContext.GetDataTokenInViewContextHierarchy(Core.Constants.Web.UmbracoContextDataToken);

            return(o != null ? o as UmbracoContext : Current.UmbracoContext);
        }