1 #region Utility 2 3 #if TRACE 4 private const string Traceformat = "\"{0}\",\"{1:yyyy-MM-dd HH:mm:ss.fffffff}\",\"{2}\",\"{3}\",\"{4}\""; 5 #endif 6 7 /// <summary> 8 /// tarce.WriteLine前缀名,时间,成员名,文件名,行号。前缀缺省是“TC”,便于检索。 9 /// </summary> 10 /// <remarks>至少.NET Framework 4.5</remarks> 11 [Conditional("TRACE")] 12 public static void TraceCaller( 13 [System.Runtime.CompilerServices.CallerMemberName] 14 string memberName = "", 15 [System.Runtime.CompilerServices.CallerFilePath] 16 string filePath = "", 17 [System.Runtime.CompilerServices.CallerLineNumber] 18 int lineNumber = 0, 19 string prefix = "[TC] ") 20 { 21 Trace.WriteLine(string.Format(Traceformat, prefix, DateTime.Now, memberName, filePath, lineNumber)); 22 } 23 24 #endregion