| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- //
- // System.Diagnostics.TraceSwtich.cs
- //
- // Comments from John R. Hicks <[email protected]> original implementation
- // can be found at: /mcs/docs/apidocs/xml/en/System.Diagnostics
- //
- // Author:
- // John R. Hicks ([email protected])
- // Jonathan Pryor ([email protected])
- //
- // (C) 2001-2002
- //
- namespace System.Diagnostics
- {
- public class TraceSwitch : Switch
- {
- public TraceSwitch(string displayName, string description)
- : base(displayName, description)
- {
- }
- public TraceLevel Level {
- get {return (TraceLevel) SwitchSetting;}
- set {
- if (!Enum.IsDefined (typeof(TraceLevel), value))
- throw new ArgumentException ("value");
- SwitchSetting = (int) value;
- }
- }
- public bool TraceError {
- get {return SwitchSetting >= (int) TraceLevel.Error;}
- }
- public bool TraceWarning {
- get {return SwitchSetting >= (int) TraceLevel.Warning;}
- }
- public bool TraceInfo {
- get {return SwitchSetting >= (int) TraceLevel.Info;}
- }
- public bool TraceVerbose {
- get {return SwitchSetting >= (int) TraceLevel.Verbose;}
- }
- // .NET accepts values over 4; they're equivalent to TraceLevel.Verbose
- // For -1, .NET crashes. (Oops!) Other negative numbers work with an
- // equivalent to setting SwitchSetting to TraceLevel.Off.
- // The logic for the accessors will cope with values >= 4, so we'll just
- // check for negative numbers.
- protected override void OnSwitchSettingChanged()
- {
- if (SwitchSetting < 0)
- SwitchSetting = (int) TraceLevel.Off;
- }
- }
- }
|