Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Pryor <jpryor@novell.com>2002-03-10 17:38:00 +0300
committerJonathan Pryor <jpryor@novell.com>2002-03-10 17:38:00 +0300
commitb83ce684efba217b0fa973fccbece6f2ce3bc5a0 (patch)
tree00f721d0c0720d6480e6c0671b855dfd3b69dce2 /mcs/class/System/System.Diagnostics/Debug.cs
parenta4c4e548cca07088afa32d248f976f30fb7403e2 (diff)
*** empty log message ***
svn path=/trunk/mcs/; revision=3036
Diffstat (limited to 'mcs/class/System/System.Diagnostics/Debug.cs')
-rw-r--r--mcs/class/System/System.Diagnostics/Debug.cs712
1 files changed, 305 insertions, 407 deletions
diff --git a/mcs/class/System/System.Diagnostics/Debug.cs b/mcs/class/System/System.Diagnostics/Debug.cs
index 5c48908dba3..2addc2064c3 100644
--- a/mcs/class/System/System.Diagnostics/Debug.cs
+++ b/mcs/class/System/System.Diagnostics/Debug.cs
@@ -1,407 +1,305 @@
-//
-// System.Diagnostics.Debug.cs
-//
-// Author: John R. Hicks <angryjohn69@nc.rr.com>
-//
-// (C) 2002
-//
-using System;
-
-namespace System.Diagnostics
-{
-
- /// <summary>
- /// Provides a set of methods to help debug code
- /// </summary>
- public sealed class Debug
- {
- private static bool autoFlush;
- private static int indentLevel;
- private static int indentSize;
- private static TraceListenerCollection listeners;
-
- static Debug()
- {
- autoFlush = false;
- indentLevel = 0;
- indentSize = 4;
- listeners = new TraceListenerCollection();
- }
-
- /// <summary>
- /// Gets or sets value indicating whether Flush should
- /// be called on the listeners.
- /// </summary>
- public static bool AutoFlush
- {
- get
- {
- return autoFlush;
- }
- set
- {
- autoFlush = value;
- }
- }
-
- /// <summary>
- /// Gets or sets indent level
- /// </summary>
- public static int IndentLevel
- {
- get
- {
- return indentLevel;
- }
- set
- {
- indentLevel = value;
- }
- }
-
- /// <summary>
- /// The number of spaces in an indent.
- /// </summary>
- public static int IndentSize
- {
- get
- {
- return indentSize;
- }
- set
- {
- indentSize = value;
- }
- }
-
- /// <summary>
- /// Returns the listeners collection
- /// </summary>
- public static TraceListenerCollection Listeners
- {
- get
- {
- return listeners;
- }
- }
-
- /// <summary>
- /// Checks for a condition, and prints a stack trace
- /// if the condition is false.
- /// </summary>
- public static void Assert(bool condition)
- {
- if(!condition) {
- WriteLine(new StackTrace().ToString());
- }
-
- }
-
- /// <summary>
- /// Checks for a condition, and displays a message if the condition
- /// is false.
- /// </summary>
- public static void Assert(bool condition, string message)
- {
- if(!condition) {
- WriteLine(message);
-
- }
-
- }
-
- /// <summary>
- /// Checks for a condtion, and displays a message and a detailed message
- /// string if the condition is false.
- /// </summary>
- public static void Assert(bool condition, string message, string detailMessage)
- {
- if(!condition) {
- WriteLine(message);
- Indent();
- WriteLine(detailMessage);
- Unindent();
-
- }
- }
-
- /// <summary>
- /// Closes the Debug buffer
- /// </summary>
- public static void Close()
- {
- foreach(TraceListener l in listeners)
- {
- l.Close();
- }
- }
-
- /// <summary>
- /// Emits the specified error message.
- /// </summary>
- public static void Fail(string message)
- {
- WriteLine(message);
-
- }
-
- /// <summary>
- /// Emits the specified error message and detailed error message.
- /// </summary>
- public static void Fail(string message, string detailMessage)
- {
- WriteLine(message);
- Indent();
- WriteLine(detailMessage);
- Unindent();
-
- }
-
- /// <summary>
- /// Flushes the listeners
- /// </summary>
- public static void Flush()
- {
- foreach(TraceListener l in listeners)
- {
- l.Flush();
- }
- }
-
- /// <summary>
- /// Increments the indent level
- /// </summary>
- public static void Indent()
- {
- indentLevel++;
- }
-
- /// <summary>
- /// Decrements the indent level
- /// </summary>
- public static void Unindent()
- {
- if(indentLevel == 0)
- return;
- else
- indentLevel--;
- }
-
- /// <summary>
- /// Writes the value of the specified object's ToString method
- /// to the listeners.
- /// </summary>
- public static void Write(object value)
- {
- foreach(TraceListener l in listeners)
- {
- l.Write(value.ToString());
- }
- }
-
- /// <summary>
- /// Writes the specified message to each listener in the Listeners collection.
- /// </summary>
- public static void Write(string message)
- {
- foreach(TraceListener l in listeners)
- {
- l.Write(message);
- }
- }
-
- /// <summary>
- /// Writes the category name and value of the specified object's
- /// ToString method to each listener in the Listeners collection.
- /// </summary>
- public static void Write(object value, string category)
- {
- foreach(TraceListener l in listeners)
- {
- l.Write("[" + category + "] " + value.ToString());
- }
- }
-
- /// <summary>
- /// Writes the category name and the specified message
- /// to each listener in the Listeners collection.
- /// </summary>
- public static void Write(string message, string category)
- {
- foreach(TraceListener l in listeners)
- {
- l.Write("[" + category + "] " + message);
- }
- }
-
- /// <summary>
- /// Writes the value of the specified object's ToString method
- /// to each of the listeners if the condition is true.
- /// </summary>
- public static void WriteIf(bool condition, object value)
- {
- if(condition)
- {
- foreach(TraceListener l in listeners)
- {
- l.Write(value.ToString());
- }
- }
- }
-
- /// <summary>
- /// Writes the specified message to each of the listeners
- /// if the specified condition is true.
- /// </summary>
- public static void WriteIf(bool condition, string message)
- {
- if(condition)
- {
- foreach(TraceListener l in listeners)
- {
- l.Write(message);
- }
- }
- }
-
- /// <summary>
- /// Writes the value of the specified object's ToString message
- /// and category to each of the listeners if the condition is true.
- /// </summary>
- public static void WriteIf(bool condition, object value, string category)
- {
- if(condition)
- {
- foreach(TraceListener l in listeners)
- {
- l.Write("[" + category + "] " + value.ToString());
- }
- }
- }
-
- /// <summary>
- /// Writes the category and specified message to each listener
- /// if the specified condition is true.
- /// </summary>
- public static void WriteIf(bool condition, string message, string category)
- {
- if(condition)
- {
- foreach(TraceListener l in listeners)
- {
- l.Write("[" + category + "] " + message);
- }
- }
-
- }
-
- /// <summary>
- /// Writes the value of the object's ToString method,
- /// followed by a line terminator, to each listener.
- /// </summary>
- public static void WriteLine(object value)
- {
- foreach(TraceListener l in listeners)
- {
- l.WriteLine(value.ToString());
- }
- }
-
- /// <summary>
- /// Writes the specified message, followed by a line terminator,
- /// to each listener.
- /// </summary>
- public static void WriteLine(string message)
- {
- foreach(TraceListener l in listeners)
- {
- l.WriteLine(message);
- }
- }
-
- /// <summary>
- /// Writes the value of the specified object's ToString method,
- /// along with a category, followed by a line terminator, to each listener.
- /// </summary>
- public static void WriteLine(object value, string category)
- {
- foreach(TraceListener l in listeners)
- {
- l.WriteLine("[" + category + "] " + value.ToString());
- }
- }
-
- /// <summary>
- /// Writes the specified category and message, followed by a line terminator,
- /// to each listener.
- /// </summary>
- public static void WriteLine(string message, string category)
- {
- foreach(TraceListener l in listeners)
- {
- l.WriteLine("[" + category + "] " + message);
- }
- }
-
- /// <summary>
- /// Writes the value of the object's ToString method
- /// to each listener if the specified condition is true.
- /// </summary>
- public static void WriteLineIf(bool condition, object value)
- {
- if(condition)
- {
- foreach(TraceListener l in listeners)
- {
- l.WriteLine(value.ToString());
- }
- }
- }
-
- /// <summary>
- /// Writes the specified message to each listener
- /// if the specified condition is true.
- /// </summary>
- public static void WriteLineIf(bool condition, string message)
- {
- if(condition)
- {
- foreach(TraceListener l in listeners)
- {
- l.WriteLine(message);
- }
- }
- }
-
- /// <summary>
- /// Writes the value of the object's ToString method, and a category
- /// to each listener if the specified condition is true.
- /// </summary>
- public static void WriteLineIf(bool condition, object value, string category)
- {
- if(condition)
- {
- foreach(TraceListener l in listeners)
- {
- l.WriteLine("[" + category + "] " + value.ToString());
- }
- }
- }
-
- /// <summary>
- /// Writes the specified category and message to each listener, followed by a line
- /// terminator, if the specified condition is true.
- /// </summary>
- public static void WriteLineIf(bool condition, string message, string category)
- {
- if(condition)
- {
- foreach(TraceListener l in listeners)
- {
- l.WriteLine("[" + category + "] " + message);
- }
- }
-
- }
- }
-}
+//
+// System.Diagnostics.Debug.cs
+//
+// Authors:
+// Jonathan Pryor (jonpryor@vt.edu)
+//
+// Comments from John R. Hicks <angryjohn69@nc.rr.com> original
+// implementation.
+//
+// (C) 2002
+//
+
+using System;
+using System.Diagnostics;
+
+namespace System.Diagnostics {
+
+ /// <summary>
+ /// Provides a set of methods to help debug code
+ /// </summary>
+ public sealed class Debug {
+
+ /// <summary>
+ /// Gets or sets value indicating whether Flush should
+ /// be called on the listeners.
+ /// </summary>
+ public static bool AutoFlush {
+ get {return TraceImpl.AutoFlush;}
+ set {TraceImpl.AutoFlush = value;}
+ }
+
+ /// <summary>
+ /// Gets or sets indent level
+ /// </summary>
+ public static int IndentLevel {
+ get {return TraceImpl.IndentLevel;}
+ set {TraceImpl.IndentLevel = value;}
+ }
+
+ /// <summary>
+ /// The number of spaces in an indent.
+ /// </summary>
+ public static int IndentSize {
+ get {return TraceImpl.IndentSize;}
+ set {TraceImpl.IndentSize = value;}
+ }
+
+ /// <summary>
+ /// Returns the listeners collection
+ /// </summary>
+ public static TraceListenerCollection Listeners {
+ get {return TraceImpl.Listeners;}
+ }
+
+ /// <summary>
+ /// Checks for a condition, and prints a stack trace
+ /// if the condition is false.
+ /// </summary>
+ [Conditional("DEBUG")]
+ public static void Assert (bool condition)
+ {
+ TraceImpl.Assert (condition);
+ }
+
+ /// <summary>
+ /// Checks for a condition, and displays a message if the condition
+ /// is false.
+ /// </summary>
+ [Conditional("DEBUG")]
+ public static void Assert (bool condition, string message)
+ {
+ TraceImpl.Assert (condition, message);
+ }
+
+ /// <summary>
+ /// Checks for a condtion, and displays a message and a detailed message
+ /// string if the condition is false.
+ /// </summary>
+ [Conditional("DEBUG")]
+ public static void Assert (bool condition, string message,
+ string detailMessage)
+ {
+ TraceImpl.Assert (condition, message, detailMessage);
+ }
+
+ /// <summary>
+ /// Closes the Debug buffer
+ /// </summary>
+ [Conditional("DEBUG")]
+ public static void Close ()
+ {
+ TraceImpl.Close ();
+ }
+
+ /// <summary>
+ /// Emits the specified error message.
+ /// </summary>
+ [Conditional("DEBUG")]
+ public static void Fail (string message)
+ {
+ TraceImpl.Fail (message);
+ }
+
+ /// <summary>
+ /// Emits the specified error message and detailed error message.
+ /// </summary>
+ [Conditional("DEBUG")]
+ public static void Fail (string message, string detailMessage)
+ {
+ TraceImpl.Fail (message, detailMessage);
+ }
+
+ /// <summary>
+ /// Flushes the listeners
+ /// </summary>
+ [Conditional("DEBUG")]
+ public static void Flush ()
+ {
+ TraceImpl.Flush ();
+ }
+
+ /// <summary>
+ /// Increments the indent level
+ /// </summary>
+ [Conditional("DEBUG")]
+ public static void Indent ()
+ {
+ TraceImpl.Indent ();
+ }
+
+ /// <summary>
+ /// Decrements the indent level
+ /// </summary>
+ [Conditional("DEBUG")]
+ public static void Unindent ()
+ {
+ TraceImpl.Unindent ();
+ }
+
+ /// <summary>
+ /// Writes the value of the specified object's ToString method
+ /// to the listeners.
+ /// </summary>
+ [Conditional("DEBUG")]
+ public static void Write (object value)
+ {
+ TraceImpl.Write (value);
+ }
+
+ /// <summary>
+ /// Writes the specified message to each listener in the Listeners
+ /// collection.
+ /// </summary>
+ [Conditional("DEBUG")]
+ public static void Write (string message)
+ {
+ TraceImpl.Write (message);
+ }
+
+ /// <summary>
+ /// Writes the category name and value of the specified object's
+ /// ToString method to each listener in the Listeners collection.
+ /// </summary>
+ [Conditional("DEBUG")]
+ public static void Write (object value, string category)
+ {
+ TraceImpl.Write (value, category);
+ }
+
+ /// <summary>
+ /// Writes the category name and the specified message
+ /// to each listener in the Listeners collection.
+ /// </summary>
+ [Conditional("DEBUG")]
+ public static void Write (string message, string category)
+ {
+ TraceImpl.Write (message, category);
+ }
+
+ /// <summary>
+ /// Writes the value of the specified object's ToString method
+ /// to each of the listeners if the condition is true.
+ /// </summary>
+ [Conditional("DEBUG")]
+ public static void WriteIf (bool condition, object value)
+ {
+ TraceImpl.WriteIf (condition, value);
+ }
+
+ /// <summary>
+ /// Writes the specified message to each of the listeners
+ /// if the specified condition is true.
+ /// </summary>
+ [Conditional("DEBUG")]
+ public static void WriteIf (bool condition, string message)
+ {
+ TraceImpl.WriteIf (condition, message);
+ }
+
+ /// <summary>
+ /// Writes the value of the specified object's ToString message
+ /// and category to each of the listeners if the condition is true.
+ /// </summary>
+ [Conditional("DEBUG")]
+ public static void WriteIf (bool condition, object value,
+ string category)
+ {
+ TraceImpl.WriteIf (condition, value, category);
+ }
+
+ /// <summary>
+ /// Writes the category and specified message to each listener
+ /// if the specified condition is true.
+ /// </summary>
+ [Conditional("DEBUG")]
+ public static void WriteIf (bool condition, string message,
+ string category)
+ {
+ TraceImpl.WriteIf (condition, message, category);
+ }
+
+ /// <summary>
+ /// Writes the value of the object's ToString method,
+ /// followed by a line terminator, to each listener.
+ /// </summary>
+ [Conditional("DEBUG")]
+ public static void WriteLine (object value)
+ {
+ TraceImpl.WriteLine (value);
+ }
+
+ /// <summary>
+ /// Writes the specified message, followed by a line terminator,
+ /// to each listener.
+ /// </summary>
+ [Conditional("DEBUG")]
+ public static void WriteLine (string message)
+ {
+ TraceImpl.WriteLine (message);
+ }
+
+ /// <summary>
+ /// Writes the value of the specified object's ToString method,
+ /// along with a category, followed by a line terminator, to each listener.
+ /// </summary>
+ [Conditional("DEBUG")]
+ public static void WriteLine (object value, string category)
+ {
+ TraceImpl.WriteLine (value, category);
+ }
+
+ /// <summary>
+ /// Writes the specified category and message, followed by a line
+ /// terminator, to each listener.
+ /// </summary>
+ [Conditional("DEBUG")]
+ public static void WriteLine (string message, string category)
+ {
+ TraceImpl.WriteLine (message, category);
+ }
+
+ /// <summary>
+ /// Writes the value of the object's ToString method
+ /// to each listener if the specified condition is true.
+ /// </summary>
+ [Conditional("DEBUG")]
+ public static void WriteLineIf (bool condition, object value)
+ {
+ TraceImpl.WriteLineIf (condition, value);
+ }
+
+ /// <summary>
+ /// Writes the specified message to each listener
+ /// if the specified condition is true.
+ /// </summary>
+ [Conditional("DEBUG")]
+ public static void WriteLineIf (bool condition, string message)
+ {
+ TraceImpl.WriteLineIf (condition, message);
+ }
+
+ /// <summary>
+ /// Writes the value of the object's ToString method, and a category
+ /// to each listener if the specified condition is true.
+ /// </summary>
+ [Conditional("DEBUG")]
+ public static void WriteLineIf (bool condition, object value,
+ string category)
+ {
+ TraceImpl.WriteLineIf (condition, value, category);
+ }
+
+ /// <summary>
+ /// Writes the specified category and message to each listener, followed
+ /// by a line terminator, if the specified condition is true.
+ /// </summary>
+ [Conditional("DEBUG")]
+ public static void WriteLineIf (bool condition, string message,
+ string category)
+ {
+ TraceImpl.WriteLineIf (condition, message, category);
+ }
+ }
+}
+