Esempio n. 1
0
        /// <exclude />
        public static Control Render(this IPage page, IEnumerable <IPagePlaceholderContent> placeholderContents, FunctionContextContainer functionContextContainer)
        {
            Verify.ArgumentNotNull(page, "page");
            Verify.ArgumentNotNull(functionContextContainer, "functionContextContainer");
            Verify.ArgumentCondition(functionContextContainer.XEmbedableMapper is XEmbeddedControlMapper,
                                     "functionContextContainer", $"Unknown or missing XEmbedableMapper on context container. Use {nameof(GetPageRenderFunctionContextContainer)}().");

            CurrentPage = page;

            using (GlobalInitializerFacade.CoreIsInitializedScope)
            {
                string url = PageUrls.BuildUrl(page);

                using (TimerProfilerFacade.CreateTimerProfiler(url ?? "(no url)"))
                {
                    var cultureInfo = page.DataSourceId.LocaleScope;
                    System.Threading.Thread.CurrentThread.CurrentCulture   = cultureInfo;
                    System.Threading.Thread.CurrentThread.CurrentUICulture = cultureInfo;

                    XEmbeddedControlMapper mapper = (XEmbeddedControlMapper)functionContextContainer.XEmbedableMapper;

                    XDocument document = TemplateInfo.GetTemplateDocument(page.TemplateId);

                    ResolvePlaceholders(document, placeholderContents);

                    Control c = Render(document, functionContextContainer, mapper, page);

                    return(c);
                }
            }
        }
Esempio n. 2
0
        /// <exclude />
        public static FunctionContextContainer GetPageRenderFunctionContextContainer()
        {
            var mapper = new XEmbeddedControlMapper();

            var contextContainer = new FunctionContextContainer
            {
                XEmbedableMapper        = mapper,
                SuppressXhtmlExceptions = GlobalSettingsFacade.PrettifyRenderFunctionExceptions ||
                                          PageRenderer.RenderingReason == RenderingReason.ScreenshotGeneration
            };

            return(contextContainer);
        }