2 // System.Web.Configuration.PagesSection
5 // Chris Toshok (toshok@ximian.com)
7 // (C) 2005-2010 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.
32 using System.ComponentModel;
33 using System.Configuration;
37 namespace System.Web.Configuration
39 public sealed class PagesSection: ConfigurationSection
41 static ConfigurationPropertyCollection properties;
42 static ConfigurationProperty asyncTimeoutProp;
43 static ConfigurationProperty autoEventWireupProp;
44 static ConfigurationProperty bufferProp;
45 static ConfigurationProperty controlsProp;
46 static ConfigurationProperty enableEventValidationProp;
47 static ConfigurationProperty enableSessionStateProp;
48 static ConfigurationProperty enableViewStateProp;
49 static ConfigurationProperty enableViewStateMacProp;
50 static ConfigurationProperty maintainScrollPositionOnPostBackProp;
51 static ConfigurationProperty masterPageFileProp;
52 static ConfigurationProperty maxPageStateFieldLengthProp;
53 static ConfigurationProperty modeProp;
54 static ConfigurationProperty namespacesProp;
55 static ConfigurationProperty pageBaseTypeProp;
56 static ConfigurationProperty pageParserFilterTypeProp;
57 static ConfigurationProperty smartNavigationProp;
58 static ConfigurationProperty styleSheetThemeProp;
59 static ConfigurationProperty tagMappingProp;
60 static ConfigurationProperty themeProp;
61 static ConfigurationProperty userControlBaseTypeProp;
62 static ConfigurationProperty validateRequestProp;
63 static ConfigurationProperty viewStateEncryptionModeProp;
64 static ConfigurationProperty clientIDModeProp;
65 static ConfigurationProperty controlRenderingCompatibilityVersionProp;
66 static PagesSection ()
68 asyncTimeoutProp = new ConfigurationProperty ("asyncTimeout", typeof (TimeSpan), TimeSpan.FromSeconds (45.0),
69 PropertyHelper.TimeSpanSecondsConverter,
70 PropertyHelper.PositiveTimeSpanValidator,
71 ConfigurationPropertyOptions.None);
72 autoEventWireupProp = new ConfigurationProperty ("autoEventWireup", typeof(bool), true);
73 bufferProp = new ConfigurationProperty ("buffer", typeof(bool), true);
74 controlsProp = new ConfigurationProperty ("controls", typeof(TagPrefixCollection), null,
75 null, null, ConfigurationPropertyOptions.None);
76 enableEventValidationProp = new ConfigurationProperty ("enableEventValidation", typeof (bool), true);
77 enableSessionStateProp = new ConfigurationProperty ("enableSessionState", typeof (string), "true");
78 enableViewStateProp = new ConfigurationProperty ("enableViewState", typeof (bool), true);
79 enableViewStateMacProp = new ConfigurationProperty ("enableViewStateMac", typeof (bool), true);
80 maintainScrollPositionOnPostBackProp = new ConfigurationProperty ("maintainScrollPositionOnPostBack", typeof (bool), false);
81 masterPageFileProp = new ConfigurationProperty ("masterPageFile", typeof (string), "");
82 maxPageStateFieldLengthProp = new ConfigurationProperty ("maxPageStateFieldLength", typeof (int), -1);
83 modeProp = new ConfigurationProperty ("compilationMode", typeof (CompilationMode), CompilationMode.Always,
84 new GenericEnumConverter (typeof (CompilationMode)), PropertyHelper.DefaultValidator,
85 ConfigurationPropertyOptions.None);
86 namespacesProp = new ConfigurationProperty ("namespaces", typeof (NamespaceCollection), null,
87 null, null, ConfigurationPropertyOptions.None);
88 pageBaseTypeProp = new ConfigurationProperty ("pageBaseType", typeof (string), "System.Web.UI.Page");
89 pageParserFilterTypeProp = new ConfigurationProperty ("pageParserFilterType", typeof (string), "");
90 smartNavigationProp = new ConfigurationProperty ("smartNavigation", typeof (bool), false);
91 styleSheetThemeProp = new ConfigurationProperty ("styleSheetTheme", typeof (string), "");
92 tagMappingProp = new ConfigurationProperty ("tagMapping", typeof (TagMapCollection), null,
93 null, null, ConfigurationPropertyOptions.None);
94 themeProp = new ConfigurationProperty ("theme", typeof (string), "");
95 userControlBaseTypeProp = new ConfigurationProperty ("userControlBaseType", typeof (string), "System.Web.UI.UserControl");
96 validateRequestProp = new ConfigurationProperty ("validateRequest", typeof (bool), true);
97 viewStateEncryptionModeProp = new ConfigurationProperty ("viewStateEncryptionMode", typeof (ViewStateEncryptionMode), ViewStateEncryptionMode.Auto,
98 new GenericEnumConverter (typeof (ViewStateEncryptionMode)), PropertyHelper.DefaultValidator,
99 ConfigurationPropertyOptions.None);
100 clientIDModeProp = new ConfigurationProperty ("clientIDMode", typeof (ClientIDMode), ClientIDMode.Predictable,
101 new GenericEnumConverter (typeof (ClientIDMode)), PropertyHelper.DefaultValidator,
102 ConfigurationPropertyOptions.None);
103 controlRenderingCompatibilityVersionProp = new ConfigurationProperty ("controlRenderingCompatibilityVersion", typeof (Version), new Version (4, 0),
104 new VersionConverter (3, 5, "The value for the property 'controlRenderingCompatibilityVersion' is not valid. The error is: The control rendering compatibility version must not be less than {1}."),
105 PropertyHelper.DefaultValidator,
106 ConfigurationPropertyOptions.None);
107 properties = new ConfigurationPropertyCollection ();
108 properties.Add (asyncTimeoutProp);
109 properties.Add (autoEventWireupProp);
110 properties.Add (bufferProp);
111 properties.Add (controlsProp);
112 properties.Add (enableEventValidationProp);
113 properties.Add (enableSessionStateProp);
114 properties.Add (enableViewStateProp);
115 properties.Add (enableViewStateMacProp);
116 properties.Add (maintainScrollPositionOnPostBackProp);
117 properties.Add (masterPageFileProp);
118 properties.Add (maxPageStateFieldLengthProp);
119 properties.Add (modeProp);
120 properties.Add (namespacesProp);
121 properties.Add (pageBaseTypeProp);
122 properties.Add (pageParserFilterTypeProp);
123 properties.Add (smartNavigationProp);
124 properties.Add (styleSheetThemeProp);
125 properties.Add (tagMappingProp);
126 properties.Add (themeProp);
127 properties.Add (userControlBaseTypeProp);
128 properties.Add (validateRequestProp);
129 properties.Add (viewStateEncryptionModeProp);
130 properties.Add (clientIDModeProp);
131 properties.Add (controlRenderingCompatibilityVersionProp);
134 public PagesSection ()
138 [TimeSpanValidator (MinValueString = "00:00:00",
139 MaxValueString = "10675199.02:48:05.4775807")]
140 [TypeConverter (typeof (TimeSpanSecondsConverter))]
141 [ConfigurationProperty ("asyncTimeout", DefaultValue = "00:00:45")]
142 public TimeSpan AsyncTimeout {
143 get { return (TimeSpan) base [asyncTimeoutProp]; }
144 set { base [asyncTimeoutProp] = value; }
147 [ConfigurationProperty ("autoEventWireup", DefaultValue = true)]
148 public bool AutoEventWireup {
149 get { return (bool) base [autoEventWireupProp]; }
150 set { base [autoEventWireupProp] = value; }
153 [ConfigurationProperty ("buffer", DefaultValue = true)]
155 get { return (bool) base [bufferProp]; }
156 set { base [bufferProp] = value; }
159 [ConfigurationProperty ("compilationMode", DefaultValue = CompilationMode.Always)]
160 public CompilationMode CompilationMode {
161 get { return (CompilationMode) base [modeProp]; }
162 set { base [modeProp] = value; }
165 [ConfigurationProperty ("controls")]
166 public TagPrefixCollection Controls {
167 get { return (TagPrefixCollection) base[controlsProp]; }
170 [ConfigurationProperty ("enableEventValidation", DefaultValue = true)]
171 public bool EnableEventValidation {
172 get { return (bool) base[enableEventValidationProp]; }
173 set { base[enableEventValidationProp] = value; }
176 [ConfigurationProperty ("enableSessionState", DefaultValue = "true")]
177 public PagesEnableSessionState EnableSessionState {
179 string enableSessionState = (string) base [enableSessionStateProp];
180 switch (enableSessionState) {
182 return PagesEnableSessionState.True;
184 return PagesEnableSessionState.False;
186 return PagesEnableSessionState.ReadOnly;
188 throw new ConfigurationErrorsException ("The 'enableSessionState'"
189 + " attribute must be one of the following values: true,"
190 + "false, ReadOnly.");
194 case PagesEnableSessionState.False:
195 base [enableSessionStateProp] = "false";
197 case PagesEnableSessionState.ReadOnly:
198 base [enableSessionStateProp] = "ReadOnly";
201 base [enableSessionStateProp] = "true";
207 [ConfigurationProperty ("enableViewState", DefaultValue = true)]
208 public bool EnableViewState {
209 get { return (bool) base[enableViewStateProp]; }
210 set { base[enableViewStateProp] = value; }
213 [ConfigurationProperty ("enableViewStateMac", DefaultValue = true)]
214 public bool EnableViewStateMac {
215 get { return (bool) base[enableViewStateMacProp]; }
216 set { base[enableViewStateMacProp] = value; }
219 [ConfigurationProperty ("maintainScrollPositionOnPostBack", DefaultValue = false)]
220 public bool MaintainScrollPositionOnPostBack {
221 get { return (bool) base[maintainScrollPositionOnPostBackProp]; }
222 set { base [maintainScrollPositionOnPostBackProp] = value; }
225 [ConfigurationProperty ("masterPageFile", DefaultValue = "")]
226 public string MasterPageFile {
227 get { return (string) base[masterPageFileProp]; }
228 set { base[masterPageFileProp] = value; }
231 [ConfigurationProperty ("maxPageStateFieldLength", DefaultValue = -1)]
232 public int MaxPageStateFieldLength {
233 get { return (int) base[maxPageStateFieldLengthProp]; }
234 set { base[maxPageStateFieldLengthProp] = value; }
237 [ConfigurationProperty ("namespaces")]
238 public NamespaceCollection Namespaces {
239 get { return (NamespaceCollection) base[namespacesProp]; }
242 [ConfigurationProperty ("pageBaseType", DefaultValue = "System.Web.UI.Page")]
243 public string PageBaseType {
244 get { return (string) base[pageBaseTypeProp]; }
245 set { base[pageBaseTypeProp] = value; }
248 [ConfigurationProperty ("pageParserFilterType", DefaultValue = "")]
249 public string PageParserFilterType {
250 get { return (string) base[pageParserFilterTypeProp]; }
251 set { base [pageParserFilterTypeProp] = value; }
254 [ConfigurationProperty ("smartNavigation", DefaultValue = false)]
255 public bool SmartNavigation {
256 get { return (bool) base[smartNavigationProp]; }
257 set { base[smartNavigationProp] = value; }
260 [ConfigurationProperty ("styleSheetTheme", DefaultValue = "")]
261 public string StyleSheetTheme {
262 get { return (string) base[styleSheetThemeProp]; }
263 set { base[styleSheetThemeProp] = value; }
266 [ConfigurationProperty ("tagMapping")]
267 public TagMapCollection TagMapping {
268 get { return (TagMapCollection) base [tagMappingProp]; }
271 [ConfigurationProperty ("theme", DefaultValue = "")]
272 public string Theme {
273 get { return (string) base[themeProp]; }
274 set { base[themeProp] = value; }
277 [ConfigurationProperty ("userControlBaseType", DefaultValue = "System.Web.UI.UserControl")]
278 public string UserControlBaseType {
279 get { return (string) base[userControlBaseTypeProp]; }
280 set { base[userControlBaseTypeProp] = value; }
283 [ConfigurationProperty ("validateRequest", DefaultValue = true)]
284 public bool ValidateRequest {
285 get { return (bool) base[validateRequestProp]; }
286 set { base[validateRequestProp] = value; }
289 [ConfigurationProperty ("viewStateEncryptionMode", DefaultValue = ViewStateEncryptionMode.Auto)]
290 public ViewStateEncryptionMode ViewStateEncryptionMode {
291 get { return (ViewStateEncryptionMode) base [viewStateEncryptionModeProp]; }
292 set { base [viewStateEncryptionModeProp] = value; }
294 [ConfigurationProperty ("clientIDMode", DefaultValue = ClientIDMode.Predictable)]
295 public ClientIDMode ClientIDMode {
296 get { return (ClientIDMode) base [clientIDModeProp]; }
297 set { base [clientIDModeProp] = value; }
300 [ConfigurationProperty ("controlRenderingCompatibilityVersion", DefaultValue = "4.0")]
301 public Version ControlRenderingCompatibilityVersion {
302 get { return (Version) base [controlRenderingCompatibilityVersionProp]; }
305 throw new ArgumentNullException ("value");
307 base [controlRenderingCompatibilityVersionProp] = value;
310 protected internal override ConfigurationPropertyCollection Properties {
311 get { return properties; }
314 protected internal override void DeserializeSection (XmlReader reader)
316 base.DeserializeSection (reader);
318 /* XXX more here?.. */