2008-06-30 Marek Habersack <mhabersack@novell.com>
[mono.git] / mcs / class / System.Web / System.Web.Configuration_2.0 / TraceSection.cs
1 //
2 // System.Web.Configuration.TraceSection
3 //
4 // Authors:
5 //      Chris Toshok (toshok@ximian.com)
6 //
7 // (C) 2005 Novell, Inc (http://www.novell.com)
8 //
9
10 //
11 // Permission is hereby granted, free of charge, to any person obtaining
12 // a copy of this software and associated documentation files (the
13 // "Software"), to deal in the Software without restriction, including
14 // without limitation the rights to use, copy, modify, merge, publish,
15 // distribute, sublicense, and/or sell copies of the Software, and to
16 // permit persons to whom the Software is furnished to do so, subject to
17 // the following conditions:
18 // 
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
21 // 
22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 //
30
31
32 using System;
33 using System.ComponentModel;
34 using System.Configuration;
35
36 #if NET_2_0
37
38 namespace System.Web.Configuration {
39
40         public sealed class TraceSection : ConfigurationSection
41         {
42                 static ConfigurationProperty enabledProp;
43                 static ConfigurationProperty localOnlyProp;
44                 static ConfigurationProperty mostRecentProp;
45                 static ConfigurationProperty pageOutputProp;
46                 static ConfigurationProperty requestLimitProp;
47                 static ConfigurationProperty traceModeProp;
48                 static ConfigurationProperty writeToDiagnosticsTraceProp;
49                 static ConfigurationPropertyCollection properties;
50
51                 static TraceSection ()
52                 {
53                         enabledProp = new ConfigurationProperty ("enabled", typeof (bool), false);
54                         localOnlyProp = new ConfigurationProperty ("localOnly", typeof (bool), true);
55                         mostRecentProp = new ConfigurationProperty ("mostRecent", typeof (bool), false);
56                         pageOutputProp = new ConfigurationProperty ("pageOutput", typeof (bool), false);
57                         requestLimitProp = new ConfigurationProperty ("requestLimit", typeof (int), 10,
58                                                                       TypeDescriptor.GetConverter (typeof (int)),
59                                                                       PropertyHelper.IntFromZeroToMaxValidator,
60                                                                       ConfigurationPropertyOptions.None);
61                         traceModeProp = new ConfigurationProperty ("traceMode", typeof (TraceDisplayMode), TraceDisplayMode.SortByTime,
62                                                                    new GenericEnumConverter (typeof (TraceDisplayMode)), null,
63                                                                    ConfigurationPropertyOptions.None);
64                         writeToDiagnosticsTraceProp = new ConfigurationProperty ("writeToDiagnosticsTrace", typeof (bool), false);
65                         properties = new ConfigurationPropertyCollection ();
66
67                         properties.Add (enabledProp);
68                         properties.Add (localOnlyProp);
69                         properties.Add (mostRecentProp);
70                         properties.Add (pageOutputProp);
71                         properties.Add (requestLimitProp);
72                         properties.Add (traceModeProp);
73                         properties.Add (writeToDiagnosticsTraceProp);
74                 }
75
76                 [ConfigurationProperty ("enabled", DefaultValue = "False")]
77                 public bool Enabled {
78                         get { return (bool) base [enabledProp];}
79                         set { base[enabledProp] = value; }
80                 }
81
82                 [ConfigurationProperty ("localOnly", DefaultValue = "True")]
83                 public bool LocalOnly {
84                         get { return (bool) base [localOnlyProp];}
85                         set { base[localOnlyProp] = value; }
86                 }
87
88                 [ConfigurationProperty ("mostRecent", DefaultValue = "False")]
89                 public bool MostRecent {
90                         get { return (bool) base [mostRecentProp];}
91                         set { base[mostRecentProp] = value; }
92                 }
93
94                 [ConfigurationProperty ("pageOutput", DefaultValue = "False")]
95                 public bool PageOutput {
96                         get { return (bool) base [pageOutputProp];}
97                         set { base[pageOutputProp] = value; }
98                 }
99
100                 [IntegerValidator (MinValue = 0, MaxValue = Int32.MaxValue)]
101                 [ConfigurationProperty ("requestLimit", DefaultValue = "10")]
102                 public int RequestLimit {
103                         get { return (int) base [requestLimitProp];}
104                         set { base[requestLimitProp] = value; }
105                 }
106
107                 [ConfigurationProperty ("traceMode", DefaultValue = "SortByTime")]
108                 public TraceDisplayMode TraceMode {
109                         get { return (TraceDisplayMode) base [traceModeProp];}
110                         set { base[traceModeProp] = value; }
111                 }
112
113                 [ConfigurationProperty ("writeToDiagnosticsTrace", DefaultValue = "False")]
114                 public bool WriteToDiagnosticsTrace {
115                         get { return (bool) base [writeToDiagnosticsTraceProp];}
116                         set { base[writeToDiagnosticsTraceProp] = value; }
117                 }
118
119                 protected override ConfigurationPropertyCollection Properties {
120                         get { return properties; }
121                 }
122
123         }
124
125 }
126
127 #endif
128