示例#1
0
        internal string GetChangedItem(string prefix,
                                       HtmlHelper <TModel> htmlHelper,
                                       object displayTemplate,
                                       ItemContainerType itemContainerType,
                                       IDictionary <string, object> htmlattributes,
                                       int index,
                                       bool normal,
                                       Func <TItem, int, string> getDynamicContainer = null
                                       )
        {
            string openTag;
            string closureTag;

            GetItemContainerTags(
                itemContainerType,
                index,
                getDynamicContainer,
                htmlattributes,
                BasicHtmlHelper.AddField(prefix, "$.Item.Value.ChangedExternally"),
                !normal,
                out openTag,
                out closureTag);
            return(string.Format("{1} {0} {2}",
                                 (Item.Changed ?
                                  GetOldContentRendering(prefix, htmlHelper, displayTemplate) :
                                  GetContentRendering(prefix, htmlHelper, displayTemplate)),
                                 openTag,
                                 closureTag));
        }
示例#2
0
        protected void GetItemContainerTags(
            ItemContainerType itemContainerType,
            int index,
            Func <TItem, int, string> getDynamicContainer,
            IDictionary <string, object> htmlattributes,
            string prefix,
            bool hidden,
            out string openTag,
            out string closureTag
            )
        {
            if (htmlattributes == null)
            {
                htmlattributes = new Dictionary <string, object>();
            }
            BasicHtmlHelper.SetAttribute(htmlattributes, "id", BasicHtmlHelper.IdFromName(prefix) + "_Container");

            if (hidden)
            {
                BasicHtmlHelper.SetDefaultStyle(htmlattributes, "display", "none");
            }
            switch (itemContainerType)
            {
            case ItemContainerType.div:
                openTag    = string.Format("<div {0}>", BasicHtmlHelper.GetAttributesString(htmlattributes));
                closureTag = "</div>";
                break;

            case ItemContainerType.span:
                openTag    = string.Format("<span {0}>", BasicHtmlHelper.GetAttributesString(htmlattributes));
                closureTag = "</span>";
                break;

            case ItemContainerType.tr:
                openTag    = string.Format("<tr {0}>", BasicHtmlHelper.GetAttributesString(htmlattributes));
                closureTag = "</tr>";
                break;

            case ItemContainerType.td:
                openTag    = string.Format("<td {0}>", BasicHtmlHelper.GetAttributesString(htmlattributes));
                closureTag = "</td>";
                break;

            case ItemContainerType.li:
                openTag    = string.Format("<li {0}>", BasicHtmlHelper.GetAttributesString(htmlattributes));
                closureTag = "</li>";
                break;

            case ItemContainerType.section:
                openTag    = string.Format("<section {0}>", BasicHtmlHelper.GetAttributesString(htmlattributes));
                closureTag = "</section>";
                break;

            case ItemContainerType.article:
                openTag    = string.Format("<article {0}>", BasicHtmlHelper.GetAttributesString(htmlattributes));
                closureTag = "</article>";
                break;

            case ItemContainerType.p:
                openTag    = string.Format("<p {0}>", BasicHtmlHelper.GetAttributesString(htmlattributes));
                closureTag = "</p>";
                break;

            default:
                if (getDynamicContainer != null)
                {
                    string tagName = getDynamicContainer(Item.OldValue, index);
                    openTag    = string.Format("<{1} {0}>", BasicHtmlHelper.GetAttributesString(htmlattributes), tagName);
                    closureTag = string.Format("</{0}>", tagName);
                }
                else
                {
                    openTag    = string.Format("<div {0}>", BasicHtmlHelper.GetAttributesString(htmlattributes));
                    closureTag = "</div>";
                }
                break;
            }
        }