remove svn:executable from .cs files
[mono.git] / mcs / class / System / System.Diagnostics / TraceSwitch.cs
1 //
2 // System.Diagnostics.TraceSwtich.cs
3 //
4 // Comments from John R. Hicks <angryjohn69@nc.rr.com> original implementation 
5 // can be found at: /mcs/docs/apidocs/xml/en/System.Diagnostics
6 //
7 // Author:
8 //      John R. Hicks (angryjohn69@nc.rr.com)
9 //      Jonathan Pryor (jonpryor@vt.edu)
10 //
11 // (C) 2001-2002
12 //
13
14 //
15 // Permission is hereby granted, free of charge, to any person obtaining
16 // a copy of this software and associated documentation files (the
17 // "Software"), to deal in the Software without restriction, including
18 // without limitation the rights to use, copy, modify, merge, publish,
19 // distribute, sublicense, and/or sell copies of the Software, and to
20 // permit persons to whom the Software is furnished to do so, subject to
21 // the following conditions:
22 // 
23 // The above copyright notice and this permission notice shall be
24 // included in all copies or substantial portions of the Software.
25 // 
26 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
27 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
28 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
29 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
30 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
31 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
32 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
33 //
34
35 namespace System.Diagnostics
36 {
37         public class TraceSwitch : Switch
38         {
39                 public TraceSwitch(string displayName, string description)
40                         : base(displayName, description)
41                 {
42                 }
43
44                 public TraceLevel Level {
45                         get {return (TraceLevel) SwitchSetting;}
46                         set {
47                                 if (!Enum.IsDefined (typeof(TraceLevel), value))
48                                         throw new ArgumentException ("value");
49                                 SwitchSetting = (int) value;
50                         }
51                 }
52
53                 public bool TraceError {
54                         get {return SwitchSetting >= (int) TraceLevel.Error;}
55                 }
56
57                 public bool TraceWarning {
58                         get {return SwitchSetting >= (int) TraceLevel.Warning;}
59                 }
60
61                 public bool TraceInfo {
62                         get {return SwitchSetting >= (int) TraceLevel.Info;}
63                 }
64
65                 public bool TraceVerbose {
66                         get {return SwitchSetting >= (int) TraceLevel.Verbose;}
67                 }
68
69                 // .NET accepts values over 4; they're equivalent to TraceLevel.Verbose
70                 // For -1, .NET crashes.  (Oops!)  Other negative numbers work with an
71                 // equivalent to setting SwitchSetting to TraceLevel.Off.
72                 // The logic for the accessors will cope with values >= 4, so we'll just
73                 // check for negative numbers.
74                 protected override void OnSwitchSettingChanged()
75                 {
76                         if (SwitchSetting < 0)
77                                 SwitchSetting = (int) TraceLevel.Off;
78                 }
79         }
80 }
81