// // System.Diagnostics.Debug.cs // // Authors: // Jonathan Pryor (jonpryor@vt.edu) // // Comments from John R. Hicks original // implementation. // // (C) 2002 // using System; using System.Diagnostics; namespace System.Diagnostics { /// /// Provides a set of methods to help debug code /// public sealed class Debug { private Debug () {} /// /// Gets or sets value indicating whether Flush should /// be called on the listeners. /// public static bool AutoFlush { get {return TraceImpl.AutoFlush;} set {TraceImpl.AutoFlush = value;} } /// /// Gets or sets indent level /// public static int IndentLevel { get {return TraceImpl.IndentLevel;} set {TraceImpl.IndentLevel = value;} } /// /// The number of spaces in an indent. /// public static int IndentSize { get {return TraceImpl.IndentSize;} set {TraceImpl.IndentSize = value;} } /// /// Returns the listeners collection /// public static TraceListenerCollection Listeners { get {return TraceImpl.Listeners;} } /// /// Checks for a condition, and prints a stack trace /// if the condition is false. /// [Conditional("DEBUG")] public static void Assert (bool condition) { TraceImpl.Assert (condition); } /// /// Checks for a condition, and displays a message if the condition /// is false. /// [Conditional("DEBUG")] public static void Assert (bool condition, string message) { TraceImpl.Assert (condition, message); } /// /// Checks for a condtion, and displays a message and a detailed message /// string if the condition is false. /// [Conditional("DEBUG")] public static void Assert (bool condition, string message, string detailMessage) { TraceImpl.Assert (condition, message, detailMessage); } /// /// Closes the Debug buffer /// [Conditional("DEBUG")] public static void Close () { TraceImpl.Close (); } /// /// Emits the specified error message. /// [Conditional("DEBUG")] public static void Fail (string message) { TraceImpl.Fail (message); } /// /// Emits the specified error message and detailed error message. /// [Conditional("DEBUG")] public static void Fail (string message, string detailMessage) { TraceImpl.Fail (message, detailMessage); } /// /// Flushes the listeners /// [Conditional("DEBUG")] public static void Flush () { TraceImpl.Flush (); } /// /// Increments the indent level /// [Conditional("DEBUG")] public static void Indent () { TraceImpl.Indent (); } /// /// Decrements the indent level /// [Conditional("DEBUG")] public static void Unindent () { TraceImpl.Unindent (); } /// /// Writes the value of the specified object's ToString method /// to the listeners. /// [Conditional("DEBUG")] public static void Write (object value) { TraceImpl.Write (value); } /// /// Writes the specified message to each listener in the Listeners /// collection. /// [Conditional("DEBUG")] public static void Write (string message) { TraceImpl.Write (message); } /// /// Writes the category name and value of the specified object's /// ToString method to each listener in the Listeners collection. /// [Conditional("DEBUG")] public static void Write (object value, string category) { TraceImpl.Write (value, category); } /// /// Writes the category name and the specified message /// to each listener in the Listeners collection. /// [Conditional("DEBUG")] public static void Write (string message, string category) { TraceImpl.Write (message, category); } /// /// Writes the value of the specified object's ToString method /// to each of the listeners if the condition is true. /// [Conditional("DEBUG")] public static void WriteIf (bool condition, object value) { TraceImpl.WriteIf (condition, value); } /// /// Writes the specified message to each of the listeners /// if the specified condition is true. /// [Conditional("DEBUG")] public static void WriteIf (bool condition, string message) { TraceImpl.WriteIf (condition, message); } /// /// Writes the value of the specified object's ToString message /// and category to each of the listeners if the condition is true. /// [Conditional("DEBUG")] public static void WriteIf (bool condition, object value, string category) { TraceImpl.WriteIf (condition, value, category); } /// /// Writes the category and specified message to each listener /// if the specified condition is true. /// [Conditional("DEBUG")] public static void WriteIf (bool condition, string message, string category) { TraceImpl.WriteIf (condition, message, category); } /// /// Writes the value of the object's ToString method, /// followed by a line terminator, to each listener. /// [Conditional("DEBUG")] public static void WriteLine (object value) { TraceImpl.WriteLine (value); } /// /// Writes the specified message, followed by a line terminator, /// to each listener. /// [Conditional("DEBUG")] public static void WriteLine (string message) { TraceImpl.WriteLine (message); } /// /// Writes the value of the specified object's ToString method, /// along with a category, followed by a line terminator, to each listener. /// [Conditional("DEBUG")] public static void WriteLine (object value, string category) { TraceImpl.WriteLine (value, category); } /// /// Writes the specified category and message, followed by a line /// terminator, to each listener. /// [Conditional("DEBUG")] public static void WriteLine (string message, string category) { TraceImpl.WriteLine (message, category); } /// /// Writes the value of the object's ToString method /// to each listener if the specified condition is true. /// [Conditional("DEBUG")] public static void WriteLineIf (bool condition, object value) { TraceImpl.WriteLineIf (condition, value); } /// /// Writes the specified message to each listener /// if the specified condition is true. /// [Conditional("DEBUG")] public static void WriteLineIf (bool condition, string message) { TraceImpl.WriteLineIf (condition, message); } /// /// Writes the value of the object's ToString method, and a category /// to each listener if the specified condition is true. /// [Conditional("DEBUG")] public static void WriteLineIf (bool condition, object value, string category) { TraceImpl.WriteLineIf (condition, value, category); } /// /// Writes the specified category and message to each listener, followed /// by a line terminator, if the specified condition is true. /// [Conditional("DEBUG")] public static void WriteLineIf (bool condition, string message, string category) { TraceImpl.WriteLineIf (condition, message, category); } } }