IfcDoc.DocumentationISO.FormatConcept C# (CSharp) Method

FormatConcept() private static method

Formats a template given an entity and optional template
private static FormatConcept ( DocProject docProject, DocEntity entity, DocConceptRoot root, DocTemplateUsage usage, DocObject>.Dictionary mapEntity, string>.Dictionary mapSchema, List listFigures, List listTables, string path, DocPublication docPublication ) : string
docProject DocProject
entity DocEntity The entity to format.
root DocConceptRoot
usage DocTemplateUsage Use definition to format, or null for all use definitions for entity.
mapEntity DocObject>.Dictionary
mapSchema string>.Dictionary
listFigures List
listTables List
path string
docPublication DocPublication
return string
        private static string FormatConcept(
            DocProject docProject, 
            DocEntity entity, 
            DocConceptRoot root, 
            DocTemplateUsage usage, 
            Dictionary<string, DocObject> mapEntity, 
            Dictionary<string, string> mapSchema, 
            List<ContentRef> listFigures, 
            List<ContentRef> listTables,
            string path,
            DocPublication docPublication)
        {
            if (usage.Definition == null)
                return String.Empty;

            StringBuilder sb = new StringBuilder();

            string anchorid = MakeLinkName(usage.Definition);

            // anchor
            sb.Append("<a id=\"");
            sb.Append(anchorid);
            sb.Append("\" />");
            sb.AppendLine();

            string conceptcaption = usage.Name;
            if(String.IsNullOrEmpty(conceptcaption))
            {
                conceptcaption = usage.Definition.Name;
            }

            // Caption
            sb.Append("<p class=\"use-head\">");
            sb.Append(conceptcaption);
            sb.Append("</p>");
            sb.AppendLine();

            // filter by particular model view
            DocModelView docModelView = null;
            if (root != null)
            {
                foreach (DocModelView docView in docProject.ModelViews)
                {
                    if (docView.ConceptRoots.Contains(root))
                    {
                        docModelView = docView;
                        break;
                    }
                }
            }

            // new (2.0): capture inherited properties too
            DocTemplateItem[] listItems = FindTemplateItems(docProject, entity, usage.Definition, docModelView);

            // add stock sentence

            // typical values: "Material Constituents", "Documents", "Aggregation", "Nesting", "Representations"
            // Usage of the <i>Material Constituents</i> concept is shown in Table XXXX.
            // Usage of the <i>Nesting</i> concept is shown in Table XXXX.
            // Usage of the <i>Aggregation</i> concept is shown in Table XXXX:

            // get link of usage
            string deflink = MakeLinkName(usage.Definition) + ".htm";

            if (listItems.Length > 0)
            {
                listTables.Add(new ContentRef(entity.Name + " " + usage.Definition.Name, entity));

                sb.Append("<p>The <a href=\"../../templates/");
                sb.Append(deflink);
                sb.Append("\">");
                sb.Append(usage.Definition.Name);
                sb.Append("</a> concept template applies to this entity as shown in Table ");
                sb.Append(listTables.Count);
                sb.Append(".");

                sb.AppendLine("<table>");
                sb.AppendLine("<tr><td>");

                string table = FormatConceptTable(docProject, docModelView, entity, root, usage, mapEntity, mapSchema);
                sb.Append(table);

                sb.AppendLine("</td></tr>");
                sb.Append("<tr><td><p class=\"table\">Table ");
                sb.Append(listTables.Count);
                sb.Append(" &mdash; ");
                sb.Append(entity.Name);
                sb.Append(" ");
                sb.Append(usage.Definition.Name);
                sb.AppendLine("</td></tr></table>");
                sb.AppendLine();
            }
            else
            {
                sb.Append("<p>The <a href=\"../../templates/");
                sb.Append(deflink);
                sb.Append("\">");
                sb.Append(usage.Definition.Name);
                sb.Append("</a> concept applies to this entity.</p>");
            }

            // add figure if it exists
            string fig = FormatFigure(docProject, entity, usage.Definition, entity.Text, listFigures, path);
            if (fig != null)
            {
                sb.Append(fig);
            }

            if (usage.Documentation != null)
            {
                sb.AppendLine(usage.Documentation); // special case if definition provides description, such as for classification
            }

            if (docPublication.Exchanges)
            {
                string req = FormatRequirements(usage, docModelView, true);
                if (req != null)
                {
                    sb.AppendLine(req);
                }
            }

            sb.AppendLine("<br/><br/>");

            return sb.ToString();
        }