mscorlib(4.0.0.0) API with additions
BooleanSwitch.cs
2 
3 namespace System.Diagnostics
4 {
6  [SwitchLevel(typeof(bool))]
7  public class BooleanSwitch : Switch
8  {
13  public bool Enabled
14  {
15  get
16  {
17  if (base.SwitchSetting != 0)
18  {
19  return true;
20  }
21  return false;
22  }
23  [SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.UnmanagedCode)]
24  set
25  {
26  base.SwitchSetting = (value ? 1 : 0);
27  }
28  }
29 
33  public BooleanSwitch(string displayName, string description)
34  : base(displayName, description)
35  {
36  }
37 
42  public BooleanSwitch(string displayName, string description, string defaultSwitchValue)
43  : base(displayName, description, defaultSwitchValue)
44  {
45  }
46 
48  protected override void OnValueChanged()
49  {
50  if (bool.TryParse(base.Value, out bool result))
51  {
52  base.SwitchSetting = (result ? 1 : 0);
53  }
54  else
55  {
56  base.OnValueChanged();
57  }
58  }
59  }
60 }
Provides a simple on/off switch that controls debugging and tracing output.
Definition: BooleanSwitch.cs:7
bool? Enabled
Gets or sets a value indicating whether the switch is enabled or disabled.
Describes a set of security permissions applied to code. This class cannot be inherited.
BooleanSwitch(string displayName, string description, string defaultSwitchValue)
Initializes a new instance of the T:System.Diagnostics.BooleanSwitch class with the specified display...
Definition: __Canon.cs:3
SecurityAction
Specifies the security actions that can be performed using declarative security.
BooleanSwitch(string displayName, string description)
Initializes a new instance of the T:System.Diagnostics.BooleanSwitch class with the specified display...
override void OnValueChanged()
Determines whether the new value of the P:System.Diagnostics.Switch.Value property can be parsed as a...
SecurityPermissionFlag
Specifies access flags for the security permission object.
Provides an abstract base class to create new debugging and tracing switches.
Definition: Switch.cs:10