X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mcs%2Fclass%2FSystem%2FSystem.Diagnostics%2FTraceSwitch.cs;h=3ddc37141df40965d16b2677eea9534ea3b01a09;hb=84943987e3ed366d3626ab276234b6c2d92ecf1d;hp=4b64d80e6ce78f4f5b454967f19773f34e97d746;hpb=67c693c673e3cc8326ce9c79166d8f24cc7c728b;p=mono.git diff --git a/mcs/class/System/System.Diagnostics/TraceSwitch.cs b/mcs/class/System/System.Diagnostics/TraceSwitch.cs index 4b64d80e6ce..3ddc37141df 100755 --- a/mcs/class/System/System.Diagnostics/TraceSwitch.cs +++ b/mcs/class/System/System.Diagnostics/TraceSwitch.cs @@ -1,97 +1,60 @@ // // System.Diagnostics.TraceSwtich.cs // +// Comments from John R. Hicks original implementation +// can be found at: /mcs/docs/apidocs/xml/en/System.Diagnostics +// // Author: // John R. Hicks (angryjohn69@nc.rr.com) +// Jonathan Pryor (jonpryor@vt.edu) // -// (C) 2001 +// (C) 2001-2002 // namespace System.Diagnostics { - /// - /// Multi-level switch to provide tracing and debug output without - /// recompiling. - /// public class TraceSwitch : Switch { - private TraceLevel level; - private bool traceError = false; - private bool traceInfo = false; - private bool traceVerbose = false; - private bool traceWarning = false; - - /// - /// Initializes a new instance - /// - /// Name for the switch - /// Description of the switch public TraceSwitch(string displayName, string description) : base(displayName, description) { } - /// - /// Gets or sets the trace level that specifies the messages to - /// output for tracing and debugging. - /// - public TraceLevel Level - { - get - { - return level; - } - set - { - level = value; + 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;} } - /// - /// Gets a value indicating whether the Level is set to Error, - /// Warning, Info, or Verbose. - /// - public bool TraceError - { - get - { - return traceError; - } + public bool TraceWarning { + get {return SwitchSetting >= (int) TraceLevel.Warning;} } - /// - /// Gets a value indicating whether the Level is set to Info or Verbose. - /// - public bool TraceInfo - { - get - { - return traceInfo; - } + public bool TraceInfo { + get {return SwitchSetting >= (int) TraceLevel.Info;} } - /// - /// Gets a value indicating whether the Level is set to Verbose. - /// - public bool TraceVerbose - { - get - { - return traceVerbose; - } + public bool TraceVerbose { + get {return SwitchSetting >= (int) TraceLevel.Verbose;} } - /// - /// Gets a value indicating whether the Level is set to - /// Warning, Info, or Verbose. - /// - public bool TraceWarning + // .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() { - get - { - return traceWarning; - } + if (SwitchSetting < 0) + SwitchSetting = (int) TraceLevel.Off; } } } +