示例#1
0
        /// <summary>
        /// Renders an Html table for Class members showing
        /// </summary>
        public RawString ClassMemberTableHtml(
            string tableAttributes  = null,
            string memberLabel      = "Member",
            string descriptionLabel = "Description"
            )
        {
            var childTopics = Topic.Topics.Where(t => GenericUtils.Inlist(t.DisplayType, "classproperty", "classmethod",
                                                                          "classevent", "classfield", "classconstructor")).ToList();


            if (childTopics.Count < 1)
            {
                return(new RawString(string.Empty));
            }


            StringBuilder sb = new StringBuilder();

            sb.Append($@"
<table class='detailtable' {tableAttributes}>
<tr><th colspan='2'>{memberLabel}</th><th>{descriptionLabel}</th></tr>
            ");


            bool alternate = false;

            foreach (var childTopic in childTopics)
            {
                sb.AppendLine("<tr" + (alternate ? " class='alternaterow'>" : ">"));

                string icon = childTopic.DisplayType;
                if (childTopic.ClassInfo.Scope == "protected")
                {
                    icon += "protected";
                }

                sb.AppendLine($"\t<td class='col-icon'><img src='~/kavadocs/icons/{icon}.png' />");
                if (childTopic.ClassInfo.IsStatic)
                {
                    sb.Append("<img src='~/_kavadocs/icons/static.gif'/>");
                }
                sb.AppendLine("\t</td>");

                string link = childTopic.GetTopicLink(WebUtility.HtmlEncode(childTopic.Title));
                sb.AppendLine($"\t<td>{link}</td>");
                sb.AppendLine($"\t<td class='col-detail'>{HtmlUtils.HtmlAbstract(childTopic.Body, 200)}");

                if (childTopic.DisplayType == "classmethod")
                {
                    sb.AppendLine($"\t\t<div><small><b>{childTopic.ClassInfo.Syntax}</b></small></div>");

                    // check for overloads
                    var overloads =
                        childTopic.Topics
                        .Where(t => t.ClassInfo.MemberName == childTopic.ClassInfo.MemberName &&
                               t.Id != childTopic.Id);
                    foreach (var overload in overloads)
                    {
                        sb.AppendLine($"\t\t<div class='syntaxoverloads'>{overload.ClassInfo.Syntax}</div>");
                    }
                }
                sb.AppendLine("\t</td>");
                sb.AppendLine("</tr>");

                alternate = !alternate;
            }
            sb.AppendLine("</table>");


            return(new RawString(sb.ToString()));
        }