public static void GetFormattedData(this Record rec, RTFBuilder rb) { try { rb.FontStyle(FontStyle.Bold).FontSize(rb.DefaultFontSize).ForeColor(KnownColor.DarkGray).AppendLine("[Formatted information]"); rb.Reset(); RecordStructure recordStructure; if (!RecordStructure.Records.TryGetValue(rec.Name, out recordStructure)) { return; } rb.FontStyle(FontStyle.Bold).ForeColor(KnownColor.DarkBlue).FontSize(rb.DefaultFontSize + 4).AppendLine(recordStructure.description); foreach (var subrec in rec.SubRecords) { if (subrec.Structure == null || subrec.Structure.elements == null || subrec.Structure.notininfo) { continue; } rb.AppendLine(); subrec.GetFormattedData(rb); } } catch { rb.ForeColor(KnownColor.Red).Append("Warning: An error occurred while processing the record. It may not conform to the structure defined in RecordStructure.xml"); } }