/// <summary> /// Serializes the given <see cref="element" /> to string. /// </summary> /// <param name="element">Object to be dumped to string using the given <paramref name="dumpStyle" />.</param> /// <param name="dumpStyle">The formatting style.</param> /// <returns></returns> public static string Dump(object element, DumpStyle dumpStyle) { var dumpOptions = new DumpOptions { DumpStyle = dumpStyle }; return(Dump(element, dumpOptions)); }
/// <summary> /// 输出当前对象的调试用字符串 /// </summary> /// <param name="style">输出的风格</param> /// <returns>表示内容的字符串</returns> public string dump(DumpStyle style = DumpStyle.None) { StringBuilder result = new StringBuilder(4096); int i = 0; foreach (MarcNode node in this) { if (result.Length > 0) { result.Append("\r\n"); } result.Append( ((style & DumpStyle.LineNumber) != 0 ? (i + 1).ToString() + ") " : "") + node.dump()); i++; } return(result.ToString()); }
public static string ToString(this ITrace trace, DumpStyle style) { switch (style) { case DumpStyle.HumanReadable: return(string.Format("{0,10} {1,10} {2}-> {3}() {4}:{5}", trace.TimeStart.ToString("0.0000"), trace.MemoryStart, Indent(trace.Level, ' '), trace.Call.Name, trace.File.Path, trace.FileLine)); case DumpStyle.HumanReadableMinimal: return(string.Format("{0} {1}> {2} {3} @ L{4}", trace.Level.ToString("D3"), Indent(trace.Level), trace.Call.Name, trace.File.Path, trace.FileLine)); case DumpStyle.Minimal: return(string.Format("{0} {1} {2} -> {3}", trace.Level.ToString("D3"), trace.Call?.Name ?? "MISSING_CALLNAME", trace.TimeStart, trace.TimeEnd)); case DumpStyle.MinimalDebug: return(string.Format(">{0} #{1} {2} {3} @ L{4}", trace.Level, trace.CallIndex, trace.Call.Name, trace.File.Path, trace.FileLine)); default: return(string.Empty); } }
/// <summary> /// Serializes the given <see cref="element" /> to string. /// </summary> /// <param name="element">Object to be dumped to string using the given <paramref name="dumpStyle" />.</param> /// <param name="dumpStyle">The formatting style.</param> /// <returns></returns> public static string Dump(this object element, DumpStyle dumpStyle) { return(ObjectDumper.Dump(element, dumpStyle)); }
public string ToString(DumpStyle style) { switch (style) { case DumpStyle.HumanReadable: return string.Format("{0,10} {1,10} {2}-> {3}() {4}:{5}", Time.ToString("0.0000"), MemoryStart, indent(Level,' '), Call, FileName, FileLine); case DumpStyle.HumanReadableMinimal: return string.Format("{0} {1}> {2} {3} @ L{4}", Level.ToString("D3"), indent(Level), Call, FileName, FileLine); case DumpStyle.Minimal: return string.Format("{0} {1} {2} -> {3}", Level.ToString("D3"), Call, Time, TimeEnd); case DumpStyle.MinimalDebug: return string.Format(">{0} #{1} {2} {3} @ L{4}", Level, FunctionNumber, Call, FileName, FileLine); default: return ""; } }