149 lines
7.6 KiB
C#
149 lines
7.6 KiB
C#
using System;
|
|
|
|
namespace System.Diagnostics
|
|
{
|
|
/// <summary>Provides a multilevel switch to control tracing and debug output without recompiling your code.</summary>
|
|
/// <filterpriority>2</filterpriority>
|
|
// Token: 0x02000107 RID: 263
|
|
[SwitchLevel(typeof(TraceLevel))]
|
|
public class TraceSwitch : Switch
|
|
{
|
|
/// <summary>Initializes a new instance of the <see cref="T:System.Diagnostics.TraceSwitch" /> class, using the specified display name and description.</summary>
|
|
/// <param name="displayName">The name to display on a user interface. </param>
|
|
/// <param name="description">The description of the switch. </param>
|
|
// Token: 0x0600097E RID: 2430 RVA: 0x00019084 File Offset: 0x00017284
|
|
public TraceSwitch(string displayName, string description)
|
|
: base(displayName, description)
|
|
{
|
|
}
|
|
|
|
/// <summary>Initializes a new instance of the <see cref="T:System.Diagnostics.TraceSwitch" /> class, using the specified display name, description, and default value for the switch. </summary>
|
|
/// <param name="displayName">The name to display on a user interface. </param>
|
|
/// <param name="description">The description of the switch. </param>
|
|
/// <param name="defaultSwitchValue">The default value of the switch.</param>
|
|
// Token: 0x0600097F RID: 2431 RVA: 0x00019090 File Offset: 0x00017290
|
|
public TraceSwitch(string displayName, string description, string defaultSwitchValue)
|
|
: base(displayName, description)
|
|
{
|
|
base.Value = defaultSwitchValue;
|
|
}
|
|
|
|
/// <summary>Gets or sets the trace level that determines the messages the switch allows.</summary>
|
|
/// <returns>One of the <see cref="T:System.Diagnostics.TraceLevel" /> values that that specifies the level of messages that are allowed by the switch.</returns>
|
|
/// <exception cref="T:System.ArgumentException">
|
|
/// <see cref="P:System.Diagnostics.TraceSwitch.Level" /> is set to a value that is not one of the <see cref="T:System.Diagnostics.TraceLevel" /> values. </exception>
|
|
/// <filterpriority>1</filterpriority>
|
|
/// <PermissionSet>
|
|
/// <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: 0x1700027A RID: 634
|
|
// (get) Token: 0x06000980 RID: 2432 RVA: 0x000190A4 File Offset: 0x000172A4
|
|
// (set) Token: 0x06000981 RID: 2433 RVA: 0x000190AC File Offset: 0x000172AC
|
|
public TraceLevel Level
|
|
{
|
|
get
|
|
{
|
|
return (TraceLevel)base.SwitchSetting;
|
|
}
|
|
set
|
|
{
|
|
if (!Enum.IsDefined(typeof(TraceLevel), value))
|
|
{
|
|
throw new ArgumentException("value");
|
|
}
|
|
base.SwitchSetting = (int)value;
|
|
}
|
|
}
|
|
|
|
/// <summary>Gets a value indicating whether the switch allows error-handling messages.</summary>
|
|
/// <returns>true if the <see cref="P:System.Diagnostics.TraceSwitch.Level" /> property is set to <see cref="F:System.Diagnostics.TraceLevel.Error" />, <see cref="F:System.Diagnostics.TraceLevel.Warning" />, <see cref="F:System.Diagnostics.TraceLevel.Info" />, or <see cref="F:System.Diagnostics.TraceLevel.Verbose" />; otherwise, false.</returns>
|
|
/// <filterpriority>1</filterpriority>
|
|
/// <PermissionSet>
|
|
/// <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="ControlEvidence" />
|
|
/// </PermissionSet>
|
|
// Token: 0x1700027B RID: 635
|
|
// (get) Token: 0x06000982 RID: 2434 RVA: 0x000190E8 File Offset: 0x000172E8
|
|
public bool TraceError
|
|
{
|
|
get
|
|
{
|
|
return base.SwitchSetting >= 1;
|
|
}
|
|
}
|
|
|
|
/// <summary>Gets a value indicating whether the switch allows warning messages.</summary>
|
|
/// <returns>true if the <see cref="P:System.Diagnostics.TraceSwitch.Level" /> property is set to <see cref="F:System.Diagnostics.TraceLevel.Warning" />, <see cref="F:System.Diagnostics.TraceLevel.Info" />, or <see cref="F:System.Diagnostics.TraceLevel.Verbose" />; otherwise, false.</returns>
|
|
/// <filterpriority>1</filterpriority>
|
|
/// <PermissionSet>
|
|
/// <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="ControlEvidence" />
|
|
/// </PermissionSet>
|
|
// Token: 0x1700027C RID: 636
|
|
// (get) Token: 0x06000983 RID: 2435 RVA: 0x000190F8 File Offset: 0x000172F8
|
|
public bool TraceWarning
|
|
{
|
|
get
|
|
{
|
|
return base.SwitchSetting >= 2;
|
|
}
|
|
}
|
|
|
|
/// <summary>Gets a value indicating whether the switch allows informational messages.</summary>
|
|
/// <returns>true if the <see cref="P:System.Diagnostics.TraceSwitch.Level" /> property is set to <see cref="F:System.Diagnostics.TraceLevel.Info" /> or <see cref="F:System.Diagnostics.TraceLevel.Verbose" />; otherwise, false. </returns>
|
|
/// <filterpriority>1</filterpriority>
|
|
/// <PermissionSet>
|
|
/// <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="ControlEvidence" />
|
|
/// </PermissionSet>
|
|
// Token: 0x1700027D RID: 637
|
|
// (get) Token: 0x06000984 RID: 2436 RVA: 0x00019108 File Offset: 0x00017308
|
|
public bool TraceInfo
|
|
{
|
|
get
|
|
{
|
|
return base.SwitchSetting >= 3;
|
|
}
|
|
}
|
|
|
|
/// <summary>Gets a value indicating whether the switch allows all messages.</summary>
|
|
/// <returns>true if the <see cref="P:System.Diagnostics.TraceSwitch.Level" /> property is set to <see cref="F:System.Diagnostics.TraceLevel.Verbose" />; otherwise, false.</returns>
|
|
/// <filterpriority>1</filterpriority>
|
|
/// <PermissionSet>
|
|
/// <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="ControlEvidence" />
|
|
/// </PermissionSet>
|
|
// Token: 0x1700027E RID: 638
|
|
// (get) Token: 0x06000985 RID: 2437 RVA: 0x00019118 File Offset: 0x00017318
|
|
public bool TraceVerbose
|
|
{
|
|
get
|
|
{
|
|
return base.SwitchSetting >= 4;
|
|
}
|
|
}
|
|
|
|
/// <summary>Updates and corrects the level for this switch.</summary>
|
|
// Token: 0x06000986 RID: 2438 RVA: 0x00019128 File Offset: 0x00017328
|
|
protected override void OnSwitchSettingChanged()
|
|
{
|
|
if (base.SwitchSetting < 0)
|
|
{
|
|
base.SwitchSetting = 0;
|
|
}
|
|
else if (base.SwitchSetting > 4)
|
|
{
|
|
base.SwitchSetting = 4;
|
|
}
|
|
}
|
|
|
|
/// <summary>Sets the <see cref="P:System.Diagnostics.Switch.SwitchSetting" /> property to the integer equivalent of the <see cref="P:System.Diagnostics.Switch.Value" /> property.</summary>
|
|
// Token: 0x06000987 RID: 2439 RVA: 0x00019160 File Offset: 0x00017360
|
|
protected override void OnValueChanged()
|
|
{
|
|
base.SwitchSetting = (int)Enum.Parse(typeof(TraceLevel), base.Value, true);
|
|
}
|
|
}
|
|
}
|