public static void Dump(this TextWriter writer, string blockName, Dictionary <string, XAQueryFieldInfo> dict, DumpOutputType outputType) { StringBuilder sbDump = new StringBuilder(); StringBuilder fieldText = new StringBuilder(); int totalSize = 0; switch (outputType) { case DumpOutputType.FormattedKeyValue: foreach (string key in dict.Keys) { fieldText.AppendLine($"\t{key} == {dict[key].FieldFormattedValue} // {dict[key].FieldDesc}"); totalSize += (int)Math.Truncate(dict[key].LengthOrFormat); } sbDump.AppendLine($"[{blockName}: sizeof() == {totalSize}]"); writer.WriteLine(sbDump.ToString() + fieldText.ToString()); break; case DumpOutputType.KeyValue: foreach (string key in dict.Keys) { fieldText.AppendLine($"\t{key} == {dict[key].FieldValue}"); totalSize += (int)Math.Truncate(dict[key].LengthOrFormat); } sbDump.AppendLine($"[{blockName}: sizeof() == {totalSize}]"); writer.WriteLine(sbDump.ToString() + fieldText.ToString()); break; case DumpOutputType.Inline: foreach (string key in dict.Keys) { fieldText.Append($"{key} = {dict[key].FieldValue}, "); } writer.WriteLine(fieldText.ToString().TrimEnd(',')); break; case DumpOutputType.Inline80Cols: foreach (string key in dict.Keys) { fieldText.Append($"{key} = {dict[key].FieldValue}, "); } string line = fieldText.ToString().TrimEnd(',');; writer.WriteLine(line.Substring(0, Math.Min(line.Length, 80)) + ((line.Length > 80) ? "..." : "")); break; } }
public void Dump(TextWriter writer, DumpOutputType outputType = DumpOutputType.FormattedKeyValue) { Dictionary <string, XAQueryFieldInfo> dict = GetFieldsInfo(); writer.Dump(this.GetBlockName(), dict, outputType); }