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
        public XDocument Render(PageContentToRender contentToRender, FunctionContextContainer functionContextContainer)
        {
            var document = TemplateInfo.GetTemplateDocument(contentToRender.Page.TemplateId);

            PageRenderer.ResolvePlaceholders(document, contentToRender.Contents);

            return(document);
        }
        private void codeActivity2_ExecuteCode(object sender, EventArgs e)
        {
            AddNewTreeRefresher addNewTreeRefresher = this.CreateAddNewTreeRefresher(this.EntityToken);

            IXmlPageTemplate newPageTemplate = this.GetBinding <IXmlPageTemplate>("NewPageTemplate");

            string newPageTemplateMarkup = null;
            Guid   copyOfId = this.GetBinding <Guid>("CopyOfId");

            if (copyOfId == Guid.Empty)
            {
                newPageTemplateMarkup = _defaultTemplateMarkup.Replace("    ", "\t");
            }
            else
            {
                XDocument copyDocument = TemplateInfo.GetTemplateDocument(copyOfId);
                newPageTemplateMarkup = copyDocument.ToString();
            }

            IPageTemplateFile pageTemplateFile = DataFacade.BuildNew <IPageTemplateFile>();

            pageTemplateFile.FolderPath = "/";
            pageTemplateFile.FileName   = string.Format("{0}.xml", PathUtil.CleanFileName(newPageTemplate.Title, true) ?? newPageTemplate.Id.ToString());
            //if (FileNameAlreadyUsed(pageTemplateFile)) pageTemplateFile.FileName = newPageTemplate.Id.ToString() + pageTemplateFile.FileName;
            pageTemplateFile.SetNewContent(newPageTemplateMarkup);

            DataFacade.AddNew <IPageTemplateFile>(pageTemplateFile, "PageTemplateFileProvider");

            newPageTemplate.PageTemplateFilePath = "/" + pageTemplateFile.FileName;
            newPageTemplate = DataFacade.AddNew <IXmlPageTemplate>(newPageTemplate);

            PageTemplateProviderRegistry.FlushTemplates();

            addNewTreeRefresher.PostRefreshMesseges(newPageTemplate.GetDataEntityToken());

            this.ExecuteAction(newPageTemplate.GetDataEntityToken(), new WorkflowActionToken(typeof(EditXmlPageTemplateWorkflow)));
        }