I was in the process of making our enhanced trace package function with Mono and I ran 
into TraceSwitch.  I don't think it was ever finished.  Included is a functioning 
TraceSwitch class which is used to determine if the trace level you're testing is 
greater/equal to the level of the Switch.  This is used to determine if our TraceQueue 
should send the trace items onto the listeners.  I didn't see any Unit Tests for 
TraceSwitch and it doesn't look like anybody really uses it.  But we do.  :)
 
Thanks,
JD Conley
Winfessor, Inc
"Life would be so much easier if we could just see the source code."
? System.Diagnostics.diff
Index: TraceSwitch.cs
===================================================================
RCS file: /mono/mcs/class/System/System.Diagnostics/TraceSwitch.cs,v
retrieving revision 1.2
diff -u -r1.2 TraceSwitch.cs
--- TraceSwitch.cs      27 May 2002 22:00:30 -0000      1.2
+++ TraceSwitch.cs      21 Dec 2002 03:41:42 -0000
@@ -4,8 +4,9 @@
 // Comments from John R. Hicks <[EMAIL PROTECTED]> original implementation 
 // can be found at: /mcs/docs/apidocs/xml/en/System.Diagnostics
 //
-// Author:
+// Authors:
 //     John R. Hicks ([EMAIL PROTECTED])
+//     JD Conley ([EMAIL PROTECTED])
 //
 // (C) 2001
 //
@@ -14,11 +15,10 @@
 {
        public class TraceSwitch : Switch
        {
-               private TraceLevel level;
-               private bool traceError = false;
-               private bool traceInfo = false;
-               private bool traceVerbose = false;
-               private bool traceWarning = false;
+               private bool _traceError = false;
+               private bool _traceInfo = false;
+               private bool _traceVerbose = false;
+               private bool _traceWarning = false;
 
                public TraceSwitch(string displayName, string description)
                        : base(displayName, description)
@@ -29,46 +29,67 @@
                {
                        get 
                        {
-                               return level;
+                               return (TraceLevel)base.SwitchSetting;
                        }
                        set
                        {
-                               level = value;
+                               this.SwitchSetting = (int)value;
                        }
 
                }
 
+               protected int SwitchSetting 
+               {
+                       get
+                       {
+                               return base.SwitchSetting;
+                       }
+                       set
+                       {
+                               
+                               //Determine if the Tracelevels are applicable
+                               //based on the new level of the switch.
+                               _traceError = value >= (int)TraceLevel.Error;
+                               _traceWarning = value >= (int)TraceLevel.Warning;
+                               _traceInfo = value >= (int)TraceLevel.Info;
+                               _traceVerbose = value == (int)TraceLevel.Verbose;
+                               
+                               base.SwitchSetting = value;
+                       }
+               }
+
                public bool TraceError
                {
                        get 
                        {
-                               return traceError;
+                               return _traceError;
                        }
                }
 
-               public bool TraceInfo
+               public bool TraceWarning
                {
-                       get 
+                       get
                        {
-                               return traceInfo;
+                               return _traceWarning;
                        }
                }
 
-               public bool TraceVerbose
+               public bool TraceInfo
                {
                        get 
                        {
-                               return traceVerbose;
+                               return _traceInfo;
                        }
                }
 
-               public bool TraceWarning
+               public bool TraceVerbose
                {
-                       get
+                       get 
                        {
-                               return traceWarning;
+                               return _traceVerbose;
                        }
                }
+
        }
 }
 


Reply via email to