BooleanSwitch.cs 1.5 KB

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