private static bool WriteTag(StringBuilder sb, DxfRawTag tag, bool haveSection, int lineNumber, string str) { bool isHeaderSection = str == CodeName.Section; string entityClass = isHeaderSection == true ? "section" : "other"; if (haveSection == true && isHeaderSection == true) { sb.AppendFormat("</div>"); haveSection = false; } if (haveSection == false && isHeaderSection == true) { haveSection = true; sb.AppendFormat("<div class=\"content\">"); sb.AppendFormat("<dt class=\"header\"><code class=\"lineHeader\">LINE</code><code class=\"codeHeader\">CODE</code><code class=\"dataHeader\">DATA</code></dt>{0}", Environment.NewLine); } sb.AppendFormat("<dt class=\"{3}\"><code class=\"line\">{4}</code><code class=\"code\">{0}:</code><code class=\"data\">{1}</code></dt>{2}", tag.Code, tag.Data, Environment.NewLine, entityClass, lineNumber); return(haveSection); }
private void ParseDxfData(StringBuilder sb, string fileName, string data) { WriteHtmlHeader(sb, fileName); WriteBodyHeader(sb, fileName); var lines = data.Split("\n".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); var tags = new List <DxfRawTag>(); DxfRawTag tag = null; bool previousName = false; bool haveSection = false; //bool haveDxfCodeForType = false; string[] entity = new string[2] { null, null }; int lineNumber = 0; foreach (var line in lines) { var str = line.Trim(); // DxfCodeForType data if (tag != null) { tag.Data = str; tags.Add(tag); haveSection = WriteTag(sb, tag, haveSection, lineNumber, str); //haveDxfCodeForType = true; tag = null; } else { if (str == DxfCodeForType && entity[0] == null) { tag = new DxfRawTag(); tag.Code = str; } else { if (entity[0] == null) { entity[0] = str; entity[1] = null; } else { entity[1] = str; WriteEntity(sb, entity, lineNumber); // entity Name previousName = entity[0] == DxfCodeForName; entity[0] = null; entity[1] = null; //haveDxfCodeForType = false; } } } lineNumber++; } WriteBodyFooter(sb, haveSection); WriteHtmlFooter(sb); }