using System; using System.Collections; using System.Collections.Specialized; namespace System.Diagnostics { /// Provides a set of methods and properties that enable applications to trace the execution of code and associate trace messages with their source. /// 1 // Token: 0x02000105 RID: 261 public class TraceSource { /// Initializes a new instance of the class, using the specified name for the source. /// The name of the source, typically the name of the application. /// /// is null. /// /// is an empty string (""). // Token: 0x06000967 RID: 2407 RVA: 0x00018960 File Offset: 0x00016B60 public TraceSource(string name) : this(name, SourceLevels.Off) { } /// Initializes a new instance of the class, using the specified name for the source and the default source level at which tracing is to occur. /// The name of the source, typically the name of the application. /// A bitwise combination of the values that specifies the default source level at which to trace. /// /// is null. /// /// is an empty string (""). // 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; } } /// Gets the custom switch attributes defined in the application configuration file. /// A containing the custom attributes for the trace switch. /// 1 // 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; } } /// Gets the collection of trace listeners for the trace source. /// A that contains the active trace listeners associated with the source. /// 1 /// /// /// // Token: 0x17000274 RID: 628 // (get) Token: 0x0600096A RID: 2410 RVA: 0x000189FC File Offset: 0x00016BFC public TraceListenerCollection Listeners { get { return this.listeners; } } /// Gets the name of the trace source. /// The name of the trace source. /// 1 // Token: 0x17000275 RID: 629 // (get) Token: 0x0600096B RID: 2411 RVA: 0x00018A04 File Offset: 0x00016C04 public string Name { get { return this.source_switch.DisplayName; } } /// Gets or sets the source switch value. /// A object representing the source switch value. /// /// is set to null. /// 1 /// /// /// // 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; } } /// Closes all the trace listeners in the trace listener collection. /// 1 /// /// /// // 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(); } } } /// Flushes all the trace listeners in the trace listener collection. /// An attempt was made to trace an event during finalization. /// 1 // 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(); } } } /// Writes trace data to the trace listeners in the collection using the specified event type, event identifier, and trace data. /// One of the values that specifies the event type of the trace data. /// A numeric identifier for the event. /// The trace data. /// An attempt was made to trace an event during finalization. /// 1 /// /// /// /// /// // 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); } } } /// Writes trace data to the trace listeners in the collection using the specified event type, event identifier, and trace data array. /// One of the values that specifies the event type of the trace data. /// A numeric identifier for the event. /// An object array containing the trace data. /// An attempt was made to trace an event during finalization. /// 1 /// /// /// /// /// // 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); } } } /// Writes a trace event message to the trace listeners in the collection using the specified event type and event identifier. /// One of the values that specifies the event type of the trace data. /// A numeric identifier for the event. /// An attempt was made to trace an event during finalization. /// 1 /// /// /// /// /// // 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); } } } /// Writes a trace event message to the trace listeners in the collection using the specified event type, event identifier, and message. /// One of the values that specifies the event type of the trace data. /// A numeric identifier for the event. /// The trace message to write. /// An attempt was made to trace an event during finalization. /// 1 /// /// /// /// /// // 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); } } } /// Writes a trace event to the trace listeners in the collection using the specified event type, event identifier, and argument array and format. /// One of the values that specifies the event type of the trace data. /// A numeric identifier for the event. /// A composite format string (see Remarks) that contains text intermixed with zero or more format items, which correspond to objects in the array. /// An object array containing zero or more objects to format. /// /// is null. /// /// 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. /// An attempt was made to trace an event during finalization. /// 1 /// /// /// /// /// // 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); } } } /// Writes an informational message to the trace listeners in the collection using the specified message. /// The informative message to write. /// An attempt was made to trace an event during finalization. /// 1 /// /// /// /// /// // Token: 0x06000975 RID: 2421 RVA: 0x00018F44 File Offset: 0x00017144 [Conditional("TRACE")] public void TraceInformation(string format) { } /// Writes an informational message to the trace listeners in the collection using the specified object array and formatting information. /// A composite format string (see Remarks) that contains text intermixed with zero or more format items, which correspond to objects in the array. /// An array containing zero or more objects to format. /// /// is null. /// /// 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. /// An attempt was made to trace an event during finalization. /// 1 /// /// /// /// /// // Token: 0x06000976 RID: 2422 RVA: 0x00018F48 File Offset: 0x00017148 [Conditional("TRACE")] public void TraceInformation(string format, params object[] args) { } /// Writes a trace transfer message to the trace listeners in the collection using the specified numeric identifier, message, and related activity identifier. /// A numeric identifier for the event. /// The trace message to write. /// A structure that identifies the related activity. /// 1 // 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); } } } /// Gets the custom attributes supported by the trace source. /// A string array naming the custom attributes supported by the trace source, or null if there are no custom attributes. // 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; } }