BooleanSwitch.cs 808 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. //
  2. // System.Diagnostics.BooleanSwitch.cs
  3. //
  4. // Author:
  5. // John R. Hicks ([email protected])
  6. // Jonathan Pryor ([email protected])
  7. //
  8. // (C) 2001-2002
  9. //
  10. namespace System.Diagnostics
  11. {
  12. /// <summary>
  13. /// Provides a simple on/off switch that controls debugging
  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. }
  25. /// <summary>
  26. /// Specifies whether the switch is enabled or disabled
  27. /// </summary>
  28. public bool Enabled {
  29. // On .NET, any non-zero value is true. Only 0 is false.
  30. get {return SwitchSetting != 0;}
  31. set {
  32. SwitchSetting = Convert.ToInt32(value);
  33. }
  34. }
  35. }
  36. }