private static ViewContentItem CreateViewContentItem(XmlNode xmlNode) { var mimeType = GetAttribute(xmlNode, "MimeType"); var contentItem = new ViewContentItem { MimeType = mimeType }; // Look for parts. var parts = new List <ViewPartContentItem>(); var partNodes = xmlNode.SelectNodes("ViewPartContentItem"); if (partNodes.Count == 0) { // The body is the content of the element. parts.Add(new ViewPartContentItem { Text = xmlNode.InnerText }); } else { foreach (XmlNode partNode in partNodes) { var name = GetAttribute(partNode, "Name"); parts.Add(new ViewPartContentItem { Name = name, Text = partNode.InnerText }); } } contentItem.Parts = parts; return(contentItem); }
private ViewEngine CreateViewEngine(Guid?verticalId, ViewContentItem contentItem) { // Create a text engine for this view. var templateEngine = CreateTextTemplateEngine(verticalId, contentItem); // Create the engine. return(new ViewEngine(templateEngine)); }
private static ViewContentItem CreateViewContentItem(ViewContentItem contentItem, ViewPartContentItem masterViewPart) { var text = masterViewPart.Text; if (contentItem.Parts != null) { text = contentItem.Parts.Aggregate(text, (current, viewPart) => current.Replace("<%=" + viewPart.Name + "%>", viewPart.Text)); } return(new ViewContentItem { MimeType = contentItem.MimeType, Parts = new List <ViewPartContentItem> { new ViewPartContentItem { Text = text } } }); }
private static ViewContentItem CreateViewContentItem(ViewContentItem contentItem, TemplateBaseContentItem masterContentItem) { var mimeType = contentItem.MimeType; // If there is a master then use it to substitute all parts into one part. if (masterContentItem != null) { var masterViewPart = GetViewPart(masterContentItem.Views, mimeType); if (masterViewPart != null) { return(CreateViewContentItem(contentItem, masterViewPart)); } } // No master so copy all parts over. return(new ViewContentItem { MimeType = contentItem.MimeType, Parts = contentItem.Parts, }); }
protected abstract ITextTemplateEngine CreateTextTemplateEngine(Guid?verticalId, ViewContentItem contentItem);