DekGenius.com
[ Team LiB ] Previous Section Next Section

DebugCF 1.0

System.Diagnostics (system.dll)sealed class

This class provides methods that allow you to print debugging information and use assertions. The Listeners collection contains a set of listeners that are responsible for reporting debugging operations through the user interface or trace log. That collection initially includes an instance of DefaultTraceListener. Add a TraceListener using the Add( ) method of the Listeners property. Use Close( ) or Flush( ) to close or flush all listeners that write output to a file, such as the TextWriterTraceListener. Set AutoFlush to true to automatically flush each listener after a write operation.

Assert( ) specifies a condition and an optional error message to display if the condition is false. If the DefaultTraceListener's AssertUiEnabled property is true, the error message is displayed as a dialog, and the user has the opportunity to abort the program, retry (test the assertion again), or ignore the failed assertion. Otherwise, the error message is written to DefaultTraceListener.LogFileName. Fail( ) acts like an assertion in which the condition is always false.

Indent( ) and Unindent( ) allow you to set the level of indentation when you call WriteLine( ). Use IndentSize to set the number of spaces corresponding to indented text. Write( ) and WriteLine( ) send output to each TraceListener in the Listeners collection, and WriteIf( ) and WriteLineIf( ) allow you to conditionally output debug information.

You can use the application configuration file to add or remove trace listeners. Look up System.Diagnostics.TraceListener in the .NET Framework SDK Documentation for details.

public sealed class Debug {
// Public Static Properties
   public static bool AutoFlush{set; get; }
   public static int IndentLevel{set; get; }
   public static int IndentSize{set; get; }
   public static TraceListenerCollection Listeners{get; }
// Public Static Methods
   public static void Assert(bool condition);
   public static void Assert(bool condition, string message);
   public static void Assert(bool condition, string message, string detailMessage);
   public static void Close( );
   public static void Fail(string message);
   public static void Fail(string message, string detailMessage);
   public static void Flush( );
   public static void Indent( );
   public static void Unindent( );
   public static void Write(object value);
   public static void Write(object value, string category);
   public static void Write(string message);
   public static void Write(string message, string category);
   public static void WriteIf(bool condition, object value);
   public static void WriteIf(bool condition, object value, string category);
   public static void WriteIf(bool condition, string message);
   public static void WriteIf(bool condition, string message, string category);
   public static void WriteLine(object value);
   public static void WriteLine(object value, string category);
   public static void WriteLine(string message);
   public static void WriteLine(string message, string category);
   public static void WriteLineIf(bool condition, object value);
   public static void WriteLineIf(bool condition, object value, string category);
   public static void WriteLineIf(bool condition, string message);
   public static void WriteLineIf(bool condition, string message, string category);
}
    [ Team LiB ] Previous Section Next Section