Files
2026-06-04 11:42:34 +02:00

385 lines
20 KiB
C#

using System;
using System.Collections;
using System.Collections.Specialized;
namespace System.Diagnostics
{
/// <summary>Provides a set of methods and properties that enable applications to trace the execution of code and associate trace messages with their source. </summary>
/// <filterpriority>1</filterpriority>
// Token: 0x02000105 RID: 261
public class TraceSource
{
/// <summary>Initializes a new instance of the <see cref="T:System.Diagnostics.TraceSource" /> class, using the specified name for the source. </summary>
/// <param name="name">The name of the source, typically the name of the application.</param>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="name" /> is null.</exception>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="name" /> is an empty string ("").</exception>
// Token: 0x06000967 RID: 2407 RVA: 0x00018960 File Offset: 0x00016B60
public TraceSource(string name)
: this(name, SourceLevels.Off)
{
}
/// <summary>Initializes a new instance of the <see cref="T:System.Diagnostics.TraceSource" /> class, using the specified name for the source and the default source level at which tracing is to occur. </summary>
/// <param name="name">The name of the source, typically the name of the application.</param>
/// <param name="defaultLevel">A bitwise combination of the <see cref="T:System.Diagnostics.SourceLevels" /> values that specifies the default source level at which to trace.</param>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="name" /> is null.</exception>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="name" /> is an empty string ("").</exception>
// Token: 0x06000968 RID: 2408 RVA: 0x0001896C File Offset: 0x00016B6C
public TraceSource(string name, SourceLevels sourceLevels)
{
if (name == null)
{
throw new ArgumentNullException("name");
}
Hashtable hashtable = null;
TraceSourceInfo traceSourceInfo = ((hashtable == null) ? null : (hashtable[name] as TraceSourceInfo));
this.source_switch = new SourceSwitch(name);
if (traceSourceInfo == null)
{
this.listeners = new TraceListenerCollection();
}
else
{
this.source_switch.Level = traceSourceInfo.Levels;
this.listeners = traceSourceInfo.Listeners;
}
}
/// <summary>Gets the custom switch attributes defined in the application configuration file.</summary>
/// <returns>A <see cref="T:System.Collections.Specialized.StringDictionary" /> containing the custom attributes for the trace switch.</returns>
/// <filterpriority>1</filterpriority>
// Token: 0x17000273 RID: 627
// (get) Token: 0x06000969 RID: 2409 RVA: 0x000189EC File Offset: 0x00016BEC
public global::System.Collections.Specialized.StringDictionary Attributes
{
get
{
return this.source_switch.Attributes;
}
}
/// <summary>Gets the collection of trace listeners for the trace source.</summary>
/// <returns>A <see cref="T:System.Diagnostics.TraceListenerCollection" /> that contains the active trace listeners associated with the source. </returns>
/// <filterpriority>1</filterpriority>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode" />
/// </PermissionSet>
// Token: 0x17000274 RID: 628
// (get) Token: 0x0600096A RID: 2410 RVA: 0x000189FC File Offset: 0x00016BFC
public TraceListenerCollection Listeners
{
get
{
return this.listeners;
}
}
/// <summary>Gets the name of the trace source.</summary>
/// <returns>The name of the trace source.</returns>
/// <filterpriority>1</filterpriority>
// Token: 0x17000275 RID: 629
// (get) Token: 0x0600096B RID: 2411 RVA: 0x00018A04 File Offset: 0x00016C04
public string Name
{
get
{
return this.source_switch.DisplayName;
}
}
/// <summary>Gets or sets the source switch value.</summary>
/// <returns>A <see cref="T:System.Diagnostics.SourceSwitch" /> object representing the source switch value.</returns>
/// <exception cref="T:System.ArgumentNullException">
/// <see cref="P:System.Diagnostics.TraceSource.Switch" /> is set to null.</exception>
/// <filterpriority>1</filterpriority>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode" />
/// </PermissionSet>
// Token: 0x17000276 RID: 630
// (get) Token: 0x0600096C RID: 2412 RVA: 0x00018A14 File Offset: 0x00016C14
// (set) Token: 0x0600096D RID: 2413 RVA: 0x00018A1C File Offset: 0x00016C1C
public SourceSwitch Switch
{
get
{
return this.source_switch;
}
set
{
if (value == null)
{
throw new ArgumentNullException("value");
}
this.source_switch = value;
}
}
/// <summary>Closes all the trace listeners in the trace listener collection.</summary>
/// <filterpriority>1</filterpriority>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode" />
/// </PermissionSet>
// Token: 0x0600096E RID: 2414 RVA: 0x00018A38 File Offset: 0x00016C38
public void Close()
{
object syncRoot = ((ICollection)this.listeners).SyncRoot;
lock (syncRoot)
{
foreach (object obj in this.listeners)
{
TraceListener traceListener = (TraceListener)obj;
traceListener.Close();
}
}
}
/// <summary>Flushes all the trace listeners in the trace listener collection.</summary>
/// <exception cref="T:System.ObjectDisposedException">An attempt was made to trace an event during finalization.</exception>
/// <filterpriority>1</filterpriority>
// Token: 0x0600096F RID: 2415 RVA: 0x00018ADC File Offset: 0x00016CDC
public void Flush()
{
object syncRoot = ((ICollection)this.listeners).SyncRoot;
lock (syncRoot)
{
foreach (object obj in this.listeners)
{
TraceListener traceListener = (TraceListener)obj;
traceListener.Flush();
}
}
}
/// <summary>Writes trace data to the trace listeners in the <see cref="P:System.Diagnostics.TraceSource.Listeners" /> collection using the specified event type, event identifier, and trace data.</summary>
/// <param name="eventType">One of the <see cref="T:System.Diagnostics.TraceEventType" /> values that specifies the event type of the trace data.</param>
/// <param name="id">A numeric identifier for the event.</param>
/// <param name="data">The trace data.</param>
/// <exception cref="T:System.ObjectDisposedException">An attempt was made to trace an event during finalization.</exception>
/// <filterpriority>1</filterpriority>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.EnvironmentPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode, ControlEvidence" />
/// </PermissionSet>
// Token: 0x06000970 RID: 2416 RVA: 0x00018B80 File Offset: 0x00016D80
[Conditional("TRACE")]
public void TraceData(TraceEventType eventType, int id, object data)
{
if (!this.source_switch.ShouldTrace(eventType))
{
return;
}
object syncRoot = ((ICollection)this.listeners).SyncRoot;
lock (syncRoot)
{
foreach (object obj in this.listeners)
{
TraceListener traceListener = (TraceListener)obj;
traceListener.TraceData(null, this.Name, eventType, id, data);
}
}
}
/// <summary>Writes trace data to the trace listeners in the <see cref="P:System.Diagnostics.TraceSource.Listeners" /> collection using the specified event type, event identifier, and trace data array.</summary>
/// <param name="eventType">One of the <see cref="T:System.Diagnostics.TraceEventType" /> values that specifies the event type of the trace data.</param>
/// <param name="id">A numeric identifier for the event.</param>
/// <param name="data">An object array containing the trace data.</param>
/// <exception cref="T:System.ObjectDisposedException">An attempt was made to trace an event during finalization.</exception>
/// <filterpriority>1</filterpriority>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.EnvironmentPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode, ControlEvidence" />
/// </PermissionSet>
// Token: 0x06000971 RID: 2417 RVA: 0x00018C40 File Offset: 0x00016E40
[Conditional("TRACE")]
public void TraceData(TraceEventType eventType, int id, params object[] data)
{
if (!this.source_switch.ShouldTrace(eventType))
{
return;
}
object syncRoot = ((ICollection)this.listeners).SyncRoot;
lock (syncRoot)
{
foreach (object obj in this.listeners)
{
TraceListener traceListener = (TraceListener)obj;
traceListener.TraceData(null, this.Name, eventType, id, data);
}
}
}
/// <summary>Writes a trace event message to the trace listeners in the <see cref="P:System.Diagnostics.TraceSource.Listeners" /> collection using the specified event type and event identifier.</summary>
/// <param name="eventType">One of the <see cref="T:System.Diagnostics.TraceEventType" /> values that specifies the event type of the trace data.</param>
/// <param name="id">A numeric identifier for the event.</param>
/// <exception cref="T:System.ObjectDisposedException">An attempt was made to trace an event during finalization.</exception>
/// <filterpriority>1</filterpriority>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.EnvironmentPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode, ControlEvidence" />
/// </PermissionSet>
// Token: 0x06000972 RID: 2418 RVA: 0x00018D00 File Offset: 0x00016F00
[Conditional("TRACE")]
public void TraceEvent(TraceEventType eventType, int id)
{
if (!this.source_switch.ShouldTrace(eventType))
{
return;
}
object syncRoot = ((ICollection)this.listeners).SyncRoot;
lock (syncRoot)
{
foreach (object obj in this.listeners)
{
TraceListener traceListener = (TraceListener)obj;
traceListener.TraceEvent(null, this.Name, eventType, id);
}
}
}
/// <summary>Writes a trace event message to the trace listeners in the <see cref="P:System.Diagnostics.TraceSource.Listeners" /> collection using the specified event type, event identifier, and message.</summary>
/// <param name="eventType">One of the <see cref="T:System.Diagnostics.TraceEventType" /> values that specifies the event type of the trace data.</param>
/// <param name="id">A numeric identifier for the event.</param>
/// <param name="message">The trace message to write.</param>
/// <exception cref="T:System.ObjectDisposedException">An attempt was made to trace an event during finalization.</exception>
/// <filterpriority>1</filterpriority>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.EnvironmentPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode, ControlEvidence" />
/// </PermissionSet>
// Token: 0x06000973 RID: 2419 RVA: 0x00018DC0 File Offset: 0x00016FC0
[Conditional("TRACE")]
public void TraceEvent(TraceEventType eventType, int id, string message)
{
if (!this.source_switch.ShouldTrace(eventType))
{
return;
}
object syncRoot = ((ICollection)this.listeners).SyncRoot;
lock (syncRoot)
{
foreach (object obj in this.listeners)
{
TraceListener traceListener = (TraceListener)obj;
traceListener.TraceEvent(null, this.Name, eventType, id, message);
}
}
}
/// <summary>Writes a trace event to the trace listeners in the <see cref="P:System.Diagnostics.TraceSource.Listeners" /> collection using the specified event type, event identifier, and argument array and format.</summary>
/// <param name="eventType">One of the <see cref="T:System.Diagnostics.TraceEventType" /> values that specifies the event type of the trace data.</param>
/// <param name="id">A numeric identifier for the event.</param>
/// <param name="format">A composite format string (see Remarks) that contains text intermixed with zero or more format items, which correspond to objects in the <paramref name="args" /> array.</param>
/// <param name="args">An object array containing zero or more objects to format.</param>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="format" /> is null. </exception>
/// <exception cref="T:System.FormatException">
/// <paramref name="format" /> is invalid.-or- The number that indicates an argument to format is less than zero, or greater than or equal to the number of specified objects to format. </exception>
/// <exception cref="T:System.ObjectDisposedException">An attempt was made to trace an event during finalization.</exception>
/// <filterpriority>1</filterpriority>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.EnvironmentPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode, ControlEvidence" />
/// </PermissionSet>
// Token: 0x06000974 RID: 2420 RVA: 0x00018E80 File Offset: 0x00017080
[Conditional("TRACE")]
public void TraceEvent(TraceEventType eventType, int id, string format, params object[] args)
{
if (!this.source_switch.ShouldTrace(eventType))
{
return;
}
object syncRoot = ((ICollection)this.listeners).SyncRoot;
lock (syncRoot)
{
foreach (object obj in this.listeners)
{
TraceListener traceListener = (TraceListener)obj;
traceListener.TraceEvent(null, this.Name, eventType, id, format, args);
}
}
}
/// <summary>Writes an informational message to the trace listeners in the <see cref="P:System.Diagnostics.TraceSource.Listeners" /> collection using the specified message.</summary>
/// <param name="message">The informative message to write.</param>
/// <exception cref="T:System.ObjectDisposedException">An attempt was made to trace an event during finalization.</exception>
/// <filterpriority>1</filterpriority>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.EnvironmentPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode, ControlEvidence" />
/// </PermissionSet>
// Token: 0x06000975 RID: 2421 RVA: 0x00018F44 File Offset: 0x00017144
[Conditional("TRACE")]
public void TraceInformation(string format)
{
}
/// <summary>Writes an informational message to the trace listeners in the <see cref="P:System.Diagnostics.TraceSource.Listeners" /> collection using the specified object array and formatting information.</summary>
/// <param name="format">A composite format string (see Remarks) that contains text intermixed with zero or more format items, which correspond to objects in the <paramref name="args" /> array.</param>
/// <param name="args">An array containing zero or more objects to format.</param>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="format" /> is null. </exception>
/// <exception cref="T:System.FormatException">
/// <paramref name="format" /> is invalid.-or- The number that indicates an argument to format is less than zero, or greater than or equal to the number of specified objects to format. </exception>
/// <exception cref="T:System.ObjectDisposedException">An attempt was made to trace an event during finalization.</exception>
/// <filterpriority>1</filterpriority>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.EnvironmentPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode, ControlEvidence" />
/// </PermissionSet>
// Token: 0x06000976 RID: 2422 RVA: 0x00018F48 File Offset: 0x00017148
[Conditional("TRACE")]
public void TraceInformation(string format, params object[] args)
{
}
/// <summary>Writes a trace transfer message to the trace listeners in the <see cref="P:System.Diagnostics.TraceSource.Listeners" /> collection using the specified numeric identifier, message, and related activity identifier.</summary>
/// <param name="id">A numeric identifier for the event.</param>
/// <param name="message">The trace message to write.</param>
/// <param name="relatedActivityId">A <see cref="T:System.Guid" /> structure that identifies the related activity.</param>
/// <filterpriority>1</filterpriority>
// Token: 0x06000977 RID: 2423 RVA: 0x00018F4C File Offset: 0x0001714C
[Conditional("TRACE")]
public void TraceTransfer(int id, string message, Guid relatedActivityId)
{
if (!this.source_switch.ShouldTrace(TraceEventType.Transfer))
{
return;
}
object syncRoot = ((ICollection)this.listeners).SyncRoot;
lock (syncRoot)
{
foreach (object obj in this.listeners)
{
TraceListener traceListener = (TraceListener)obj;
traceListener.TraceTransfer(null, this.Name, id, message, relatedActivityId);
}
}
}
/// <summary>Gets the custom attributes supported by the trace source.</summary>
/// <returns>A string array naming the custom attributes supported by the trace source, or null if there are no custom attributes.</returns>
// Token: 0x06000978 RID: 2424 RVA: 0x00019010 File Offset: 0x00017210
protected virtual string[] GetSupportedAttributes()
{
return null;
}
// Token: 0x04000317 RID: 791
private SourceSwitch source_switch;
// Token: 0x04000318 RID: 792
private TraceListenerCollection listeners;
}
}