示例#1
0
        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);
        }
示例#2
0
        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));
        }
示例#3
0
        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
                    }
                }
            });
        }
示例#4
0
        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,
            });
        }
示例#5
0
 protected abstract ITextTemplateEngine CreateTextTemplateEngine(Guid?verticalId, ViewContentItem contentItem);