mscorlib(4.0.0.0) API with additions
Trace.cs
2 
3 namespace System.Diagnostics
4 {
6  public sealed class Trace
7  {
8  private static volatile CorrelationManager correlationManager;
9 
13  {
14  [HostProtection(SecurityAction.LinkDemand, SharedState = true)]
15  get
16  {
18  return TraceInternal.Listeners;
19  }
20  }
21 
25  public static bool AutoFlush
26  {
27  [SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.UnmanagedCode)]
28  get
29  {
30  return TraceInternal.AutoFlush;
31  }
32  [SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.UnmanagedCode)]
33  set
34  {
35  TraceInternal.AutoFlush = value;
36  }
37  }
38 
42  public static bool UseGlobalLock
43  {
44  [SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.UnmanagedCode)]
45  get
46  {
47  return TraceInternal.UseGlobalLock;
48  }
49  [SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.UnmanagedCode)]
50  set
51  {
52  TraceInternal.UseGlobalLock = value;
53  }
54  }
55 
59  {
60  [SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.UnmanagedCode)]
61  get
62  {
63  if (correlationManager == null)
64  {
65  correlationManager = new CorrelationManager();
66  }
67  return correlationManager;
68  }
69  }
70 
73  public static int IndentLevel
74  {
75  get
76  {
77  return TraceInternal.IndentLevel;
78  }
79  set
80  {
81  TraceInternal.IndentLevel = value;
82  }
83  }
84 
87  public static int IndentSize
88  {
89  get
90  {
91  return TraceInternal.IndentSize;
92  }
93  set
94  {
95  TraceInternal.IndentSize = value;
96  }
97  }
98 
99  private Trace()
100  {
101  }
102 
104  [Conditional("TRACE")]
105  public static void Flush()
106  {
107  TraceInternal.Flush();
108  }
109 
111  [Conditional("TRACE")]
112  public static void Close()
113  {
114  new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Demand();
115  TraceInternal.Close();
116  }
117 
120  [Conditional("TRACE")]
121  public static void Assert(bool condition)
122  {
123  TraceInternal.Assert(condition);
124  }
125 
129  [Conditional("TRACE")]
130  public static void Assert(bool condition, string message)
131  {
132  TraceInternal.Assert(condition, message);
133  }
134 
139  [Conditional("TRACE")]
140  public static void Assert(bool condition, string message, string detailMessage)
141  {
142  TraceInternal.Assert(condition, message, detailMessage);
143  }
144 
147  [Conditional("TRACE")]
148  public static void Fail(string message)
149  {
150  TraceInternal.Fail(message);
151  }
152 
156  [Conditional("TRACE")]
157  public static void Fail(string message, string detailMessage)
158  {
159  TraceInternal.Fail(message, detailMessage);
160  }
161 
163  public static void Refresh()
164  {
165  DiagnosticsConfiguration.Refresh();
166  Switch.RefreshAll();
167  TraceSource.RefreshAll();
168  TraceInternal.Refresh();
169  }
170 
173  [Conditional("TRACE")]
174  public static void TraceInformation(string message)
175  {
176  TraceInternal.TraceEvent(TraceEventType.Information, 0, message, null);
177  }
178 
182  [Conditional("TRACE")]
183  public static void TraceInformation(string format, params object[] args)
184  {
185  TraceInternal.TraceEvent(TraceEventType.Information, 0, format, args);
186  }
187 
190  [Conditional("TRACE")]
191  public static void TraceWarning(string message)
192  {
193  TraceInternal.TraceEvent(TraceEventType.Warning, 0, message, null);
194  }
195 
199  [Conditional("TRACE")]
200  public static void TraceWarning(string format, params object[] args)
201  {
202  TraceInternal.TraceEvent(TraceEventType.Warning, 0, format, args);
203  }
204 
207  [Conditional("TRACE")]
208  public static void TraceError(string message)
209  {
210  TraceInternal.TraceEvent(TraceEventType.Error, 0, message, null);
211  }
212 
216  [Conditional("TRACE")]
217  public static void TraceError(string format, params object[] args)
218  {
219  TraceInternal.TraceEvent(TraceEventType.Error, 0, format, args);
220  }
221 
224  [Conditional("TRACE")]
225  public static void Write(string message)
226  {
227  TraceInternal.Write(message);
228  }
229 
232  [Conditional("TRACE")]
233  public static void Write(object value)
234  {
235  TraceInternal.Write(value);
236  }
237 
241  [Conditional("TRACE")]
242  public static void Write(string message, string category)
243  {
244  TraceInternal.Write(message, category);
245  }
246 
250  [Conditional("TRACE")]
251  public static void Write(object value, string category)
252  {
253  TraceInternal.Write(value, category);
254  }
255 
258  [Conditional("TRACE")]
259  public static void WriteLine(string message)
260  {
261  TraceInternal.WriteLine(message);
262  }
263 
266  [Conditional("TRACE")]
267  public static void WriteLine(object value)
268  {
269  TraceInternal.WriteLine(value);
270  }
271 
275  [Conditional("TRACE")]
276  public static void WriteLine(string message, string category)
277  {
278  TraceInternal.WriteLine(message, category);
279  }
280 
284  [Conditional("TRACE")]
285  public static void WriteLine(object value, string category)
286  {
287  TraceInternal.WriteLine(value, category);
288  }
289 
294  [Conditional("TRACE")]
295  public static void WriteIf(bool condition, string message)
296  {
297  TraceInternal.WriteIf(condition, message);
298  }
299 
304  [Conditional("TRACE")]
305  public static void WriteIf(bool condition, object value)
306  {
307  TraceInternal.WriteIf(condition, value);
308  }
309 
315  [Conditional("TRACE")]
316  public static void WriteIf(bool condition, string message, string category)
317  {
318  TraceInternal.WriteIf(condition, message, category);
319  }
320 
326  [Conditional("TRACE")]
327  public static void WriteIf(bool condition, object value, string category)
328  {
329  TraceInternal.WriteIf(condition, value, category);
330  }
331 
336  [Conditional("TRACE")]
337  public static void WriteLineIf(bool condition, string message)
338  {
339  TraceInternal.WriteLineIf(condition, message);
340  }
341 
346  [Conditional("TRACE")]
347  public static void WriteLineIf(bool condition, object value)
348  {
349  TraceInternal.WriteLineIf(condition, value);
350  }
351 
357  [Conditional("TRACE")]
358  public static void WriteLineIf(bool condition, string message, string category)
359  {
360  TraceInternal.WriteLineIf(condition, message, category);
361  }
362 
368  [Conditional("TRACE")]
369  public static void WriteLineIf(bool condition, object value, string category)
370  {
371  TraceInternal.WriteLineIf(condition, value, category);
372  }
373 
375  [Conditional("TRACE")]
376  public static void Indent()
377  {
378  TraceInternal.Indent();
379  }
380 
382  [Conditional("TRACE")]
383  public static void Unindent()
384  {
385  TraceInternal.Unindent();
386  }
387  }
388 }
Provides a thread-safe list of T:System.Diagnostics.TraceListener objects.
static void WriteLine(string message)
Writes a message to the trace listeners in the P:System.Diagnostics.Trace.Listeners collection.
Definition: Trace.cs:259
static void Indent()
Increases the current P:System.Diagnostics.Trace.IndentLevel by one.
Definition: Trace.cs:376
static void WriteIf(bool condition, object value)
Writes the value of the object's M:System.Object.ToString method to the trace listeners in the P:Syst...
Definition: Trace.cs:305
Describes a set of security permissions applied to code. This class cannot be inherited.
static void WriteIf(bool condition, string message, string category)
Writes a category name and message to the trace listeners in the P:System.Diagnostics....
Definition: Trace.cs:316
static int IndentLevel
Gets or sets the indent level.
Definition: Trace.cs:74
static void Fail(string message)
Emits the specified error message.
Definition: Trace.cs:148
static void Assert(bool condition, string message)
Checks for a condition; if the condition is false, outputs a specified message and displays a message...
Definition: Trace.cs:130
static void Write(object value)
Writes the value of the object's M:System.Object.ToString method to the trace listeners in the P:Syst...
Definition: Trace.cs:233
Provides a set of methods and properties that help you trace the execution of your code....
Definition: Trace.cs:6
static void WriteLine(object value, string category)
Writes a category name and the value of the object's M:System.Object.ToString method to the trace lis...
Definition: Trace.cs:285
Exposes state that might be shared between threads.
Definition: __Canon.cs:3
static CorrelationManager CorrelationManager
Gets the correlation manager for the thread for this trace.
Definition: Trace.cs:59
static int IndentSize
Gets or sets the number of spaces in an indent.
Definition: Trace.cs:88
static void WriteLineIf(bool condition, string message)
Writes a message to the trace listeners in the P:System.Diagnostics.Trace.Listeners collection if a c...
Definition: Trace.cs:337
static void TraceWarning(string format, params object[] args)
Writes a warning message to the trace listeners in the P:System.Diagnostics.Trace....
Definition: Trace.cs:200
static void Close()
Flushes the output buffer, and then closes the P:System.Diagnostics.Trace.Listeners.
Definition: Trace.cs:112
static void TraceInformation(string format, params object[] args)
Writes an informational message to the trace listeners in the P:System.Diagnostics....
Definition: Trace.cs:183
static void Assert(bool condition, string message, string detailMessage)
Checks for a condition; if the condition is false, outputs two specified messages and displays a mess...
Definition: Trace.cs:140
SecurityAction
Specifies the security actions that can be performed using declarative security.
Correlates traces that are part of a logical transaction.
Provides a set of methods and properties that enable applications to trace the execution of code and ...
Definition: TraceSource.cs:9
static void WriteLine(string message, string category)
Writes a category name and message to the trace listeners in the P:System.Diagnostics....
Definition: Trace.cs:276
static void Write(string message)
Writes a message to the trace listeners in the P:System.Diagnostics.Trace.Listeners collection.
Definition: Trace.cs:225
static void Assert(bool condition)
Checks for a condition; if the condition is false, displays a message box that shows the call stack.
Definition: Trace.cs:121
static void TraceError(string format, params object[] args)
Writes an error message to the trace listeners in the P:System.Diagnostics.Trace.Listeners collection...
Definition: Trace.cs:217
static void WriteLine(object value)
Writes the value of the object's M:System.Object.ToString method to the trace listeners in the P:Syst...
Definition: Trace.cs:267
static void TraceInformation(string message)
Writes an informational message to the trace listeners in the P:System.Diagnostics....
Definition: Trace.cs:174
static void Write(object value, string category)
Writes a category name and the value of the object's M:System.Object.ToString method to the trace lis...
Definition: Trace.cs:251
static void TraceError(string message)
Writes an error message to the trace listeners in the P:System.Diagnostics.Trace.Listeners collection...
Definition: Trace.cs:208
TraceEventType
Identifies the type of event that has caused the trace.
static void Flush()
Flushes the output buffer, and causes buffered data to be written to the P:System....
Definition: Trace.cs:105
void Demand()
Forces a T:System.Security.SecurityException at run time if all callers higher in the call stack have...
static bool AutoFlush
Gets or sets whether M:System.Diagnostics.Trace.Flush should be called on the P:System....
Definition: Trace.cs:26
static void WriteIf(bool condition, object value, string category)
Writes a category name and the value of the object's M:System.Object.ToString method to the trace lis...
Definition: Trace.cs:327
static void Refresh()
Refreshes the trace configuration data.
Definition: Trace.cs:163
static void WriteLineIf(bool condition, object value)
Writes the value of the object's M:System.Object.ToString method to the trace listeners in the P:Syst...
Definition: Trace.cs:347
static void WriteIf(bool condition, string message)
Writes a message to the trace listeners in the P:System.Diagnostics.Trace.Listeners collection if a c...
Definition: Trace.cs:295
static void WriteLineIf(bool condition, object value, string category)
Writes a category name and the value of the object's M:System.Object.ToString method to the trace lis...
Definition: Trace.cs:369
static void Write(string message, string category)
Writes a category name and a message to the trace listeners in the P:System.Diagnostics....
Definition: Trace.cs:242
static TraceListenerCollection Listeners
Gets the collection of listeners that is monitoring the trace output.
Definition: Trace.cs:13
SecurityPermissionFlag
Specifies access flags for the security permission object.
static void Unindent()
Decreases the current P:System.Diagnostics.Trace.IndentLevel by one.
Definition: Trace.cs:383
static void WriteLineIf(bool condition, string message, string category)
Writes a category name and message to the trace listeners in the P:System.Diagnostics....
Definition: Trace.cs:358
static bool UseGlobalLock
Gets or sets a value indicating whether the global lock should be used.
Definition: Trace.cs:43
Provides an abstract base class to create new debugging and tracing switches.
Definition: Switch.cs:10
static void TraceWarning(string message)
Writes a warning message to the trace listeners in the P:System.Diagnostics.Trace....
Definition: Trace.cs:191
static void Fail(string message, string detailMessage)
Emits an error message, and a detailed error message.
Definition: Trace.cs:157