IfcDoc.DocumentationISO.FormatField C# (CSharp) Method

FormatField() private static method

private static FormatField ( DocProject docProject, string content, string fieldname, string fieldtype, string fieldvalue ) : string
docProject DocProject
content string
fieldname string
fieldtype string
fieldvalue string
return string
        private static string FormatField(DocProject docProject, string content /*deprecate*/, string fieldname, string fieldtype/*deprecate*/, string fieldvalue/*deprecate*/)
        {
            DocDefinition docDef = docProject.GetDefinition(fieldname);

            // hyperlink to enumerators
            if (docDef is DocEnumeration)
            {
                // hyperlink to enumeration definition

                // replace it with hyperlink
                DocSchema docSchema = docProject.GetSchemaOfDefinition(docDef);
                string relative = @"../../";
                string hyperlink = relative + docSchema.Name.ToLower() + @"/lexical/" + docDef.Name.ToLower() + ".htm";
                string format = "<a href=\"" + hyperlink + "\">" + fieldvalue + "</a>";

                return format;// content.Replace(fieldname, format);
            }
            else if (docDef is DocEntity || docDef is DocType)//fieldvalue != null && fieldvalue.StartsWith("Ifc") && docProject.GetDefinition(fieldvalue) != null)
            {
                // replace it with hyperlink
                DocSchema docSchema = docProject.GetSchemaOfDefinition(docDef);
                string relative = @"../../";
                string hyperlink = relative + docSchema.Name.ToLower() + @"/lexical/" + docDef.Name.ToLower() + ".htm";
                string format = "<a href=\"" + hyperlink + "\">" + fieldvalue + "</a>";

                return format;// content.Replace(fieldname, format);
            }
            else //if (docDef == null)
            {
                // hyperlink to property set definition
                DocSchema docSchema = null;
                DocObject docObj = docProject.FindPropertySet(fieldvalue, out docSchema);
                if (docObj is DocPropertySet)
                {
                    string relative = @"../../";
                    string hyperlink = relative + docSchema.Name.ToLowerInvariant() + @"/pset/" + docObj.Name.ToLower() + ".htm"; // case-sensitive on linux -- need to make schema all lowercase
                    string format = "<a href=\"" + hyperlink + "\">" + fieldvalue + "</a>";
                    return format;// content.Replace(fieldname, format);
                }
                else
                {
                    docObj = docProject.FindPropertyEnumeration(fieldvalue, out docSchema);
                    if(docObj is DocPropertyEnumeration)
                    {
                        string relative = @"../../";
                        string hyperlink = relative + docSchema.Name.ToLowerInvariant() + @"/pset/" + docObj.Name.ToLower() + ".htm"; // case-sensitive on linux -- need to make schema all lowercase
                        string format = "<a href=\"" + hyperlink + "\">" + fieldvalue + "</a>";
                        return format;// content.Replace(fieldname, format);
                    }
                    else
                    {
                        docObj = docProject.FindQuantitySet(fieldvalue, out docSchema);
                        if (docObj is DocQuantitySet)
                        {
                            string relative = @"../../";
                            string hyperlink = relative + docSchema.Name.ToLowerInvariant() + @"/qset/" + docObj.Name.ToLower() + ".htm"; // case-sentive on linux -- need to make schema all lowercase
                            string format = "<a href=\"" + hyperlink + "\">" + fieldvalue + "</a>";
                            return format;// content.Replace(fieldname, format);
                        }

                    }
                }

                if (docObj == null)
                {
                    // simple replace -- hyperlink may markup value later
                    return fieldvalue;// content.Replace(fieldname, fieldvalue);
                }
            }
            /*
            else
            {
                // simple replace -- hyperlink may markup value later
                return content.Replace(fieldname, fieldvalue);
            }*/

            return content;
        }