2001-09-09 Nick Drochak <ndrochak@gol.com>
[mono.git] / mcs / class / System / System.Diagnostics / BooleanSwitch.cs
1 //
2 // System.Diagnostics.BooleanSwitch.cs
3 //
4 // Author:
5 //      John R. Hicks (angryjohn69@nc.rr.com)
6 //
7 // (C) 2001
8 //
9
10 namespace System.Diagnostics
11 {
12         /// <summary>
13         /// Provides a simple on/off switch that controls debuggina
14         /// and tracing output
15         /// </summary>
16         public class BooleanSwitch : Switch
17         {
18                 /// <summary>
19                 /// Initializes a new instance
20                 /// </summary>
21                 public BooleanSwitch(string displayName, string description)
22                         : base(displayName, description)
23                 {
24                         SwitchSetting = (int)BooleanSwitchSetting.False;
25                 }
26
27                 // =================== Properties ===================
28
29                 /// <summary>
30                 /// Specifies whether the switch is enabled or disabled
31                 /// </summary>
32                 public bool Enabled
33                 {
34                         get
35                         {
36                                 if((int)BooleanSwitchSetting.False == SwitchSetting) {
37                                         return false;
38                                 }
39                                 else {
40                                         return true;
41                                 }
42                         }
43                         set
44                         {
45                                 if(value) {
46                                         SwitchSetting = (int)BooleanSwitchSetting.True;
47                                 }
48                                 else {
49                                         SwitchSetting = (int)BooleanSwitchSetting.False;
50                                 }
51                         }
52                 }
53
54                 private enum BooleanSwitchSetting : int {
55                         True = 1, False = 0
56                 }
57         }
58
59 }