2 // System.Web.Configuation.TraceConfigurationHandler
5 // Jackson Harper (jackson@ximian.com)
7 // (C) 2004 Novell, Inc (http://www.novell.com)
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:
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
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.
34 using System.Configuration;
36 namespace System.Web.Configuration {
38 internal class TraceConfigurationHandler : IConfigurationSectionHandler {
40 public object Create (object parent, object context, XmlNode section)
42 TraceConfig config = new TraceConfig ();
44 string enabled_str = AttValue ("enabled", section);
45 if (enabled_str != null) {
47 config.Enabled = Boolean.Parse (enabled_str);
49 ThrowException ("The 'enabled' attribute is case sensitive" +
50 " and must be set to 'true' or 'false'.", section);
54 string local_str = AttValue ("localOnly", section);
55 if (local_str != null) {
57 config.LocalOnly = Boolean.Parse (local_str);
59 ThrowException ("The 'localOnly' attribute is case sensitive" +
60 " and must be set to 'true' or 'false'.", section);
64 string page_str = AttValue ("pageOutput", section);
65 if (page_str != null) {
67 config.PageOutput = Boolean.Parse (page_str);
69 ThrowException ("The 'pageOutput' attribute is case sensitive" +
70 " and must be set to 'true' or 'false'.", section);
74 string limit_str = AttValue ("requestLimit", section);
75 if (limit_str != null) {
77 config.RequestLimit = Int32.Parse (limit_str);
79 ThrowException ("The 'requestLimit' attribute must be an integer value.",
84 string trace_str = AttValue ("traceMode", section);
85 if (trace_str != null) {
87 config.TraceMode = (TraceMode) Enum.Parse (typeof (TraceMode), trace_str);
89 ThrowException ("The 'traceMode' attribute is case sensitive and must be" +
90 " one of the following values: SortByTime, SortByCategory.",
98 // A few methods to save some typing
99 static string AttValue (string name, XmlNode node)
101 return HandlersUtil.ExtractAttributeValue (name, node, true);
104 static void ThrowException (string message, XmlNode node)
106 HandlersUtil.ThrowException (message, node);