2 // System.Web.Configuration.PagesConfigurationHandler
5 // Gonzalo Paniagua Javier (gonzalo@ximian.com)
7 // (C) 2004 Novell, Inc (http://www.novel.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.
31 using System.Configuration;
34 namespace System.Web.Configuration
36 class PagesConfigurationHandler : IConfigurationSectionHandler
38 public object Create (object parent, object configContext, XmlNode section)
40 PagesConfiguration config = new PagesConfiguration (parent);
42 if (section.HasChildNodes)
43 HandlersUtil.ThrowException ("No child nodes allowed here.", section);
45 string attvalue = AttValue ("buffer", section);
47 config.Buffer = GetBool ("buffer", attvalue, section);
49 attvalue = AttValue ("enableSessionState", section);
50 if (attvalue != null) {
51 if (attvalue != "true" && attvalue != "false" && attvalue != "ReadOnly")
52 HandlersUtil.ThrowException ("Invalid value for 'enableSessionState'", section);
54 config.EnableSessionState = attvalue;
57 attvalue = AttValue ("enableViewState", section);
59 config.EnableViewState = GetBool ("enableViewState", attvalue, section);
61 attvalue = AttValue ("enableViewStateMac", section);
63 config.EnableViewStateMac = GetBool ("enableViewStateMac", attvalue, section);
65 attvalue = AttValue ("smartNavigation", section);
67 config.SmartNavigation = GetBool ("smartNavigation", attvalue, section);
69 attvalue = AttValue ("autoEventWireup", section);
71 config.AutoEventWireup = GetBool ("autoEventWireup", attvalue, section);
73 attvalue = AttValue ("validateRequest", section);
75 config.ValidateRequest = GetBool ("validateRequest", attvalue, section);
77 attvalue = AttValue ("pageBaseType", section);
78 if (attvalue != null) {
79 string v = attvalue.Trim ();
81 HandlersUtil.ThrowException ("pageBaseType is empty.", section);
83 config.PageBaseType = v;
86 attvalue = AttValue ("userControlBaseType", section);
87 if (attvalue != null) {
88 string v = attvalue.Trim ();
90 HandlersUtil.ThrowException ("userControlBaseType is empty.", section);
92 config.UserControlBaseType = v;
95 if (section.Attributes == null || section.Attributes.Count != 0)
96 HandlersUtil.ThrowException ("Unknown attribute(s).", section);
101 static bool GetBool (string name, string value, XmlNode section)
106 if (value != "false")
107 HandlersUtil.ThrowException ("Invalid boolean value for '" + name + "'", section);
112 // A few methods to save some typing
113 static string AttValue (string name, XmlNode node)
115 return HandlersUtil.ExtractAttributeValue (name, node, true);