2 // System.Web.Configuration.PagesSection
5 // Chris Toshok (toshok@ximian.com)
7 // (C) 2005 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
.ComponentModel
;
35 using System
.Configuration
;
39 namespace System
.Web
.Configuration
41 public sealed class PagesSection
: ConfigurationSection
43 static ConfigurationPropertyCollection properties
;
44 static ConfigurationProperty asyncTimeoutProp
;
45 static ConfigurationProperty autoEventWireupProp
;
46 static ConfigurationProperty bufferProp
;
47 static ConfigurationProperty controlsProp
;
48 static ConfigurationProperty enableEventValidationProp
;
49 static ConfigurationProperty enableSessionStateProp
;
50 static ConfigurationProperty enableViewStateProp
;
51 static ConfigurationProperty enableViewStateMacProp
;
52 static ConfigurationProperty maintainScrollPositionOnPostBackProp
;
53 static ConfigurationProperty masterPageFileProp
;
54 static ConfigurationProperty maxPageStateFieldLengthProp
;
55 static ConfigurationProperty modeProp
;
56 static ConfigurationProperty namespacesProp
;
57 static ConfigurationProperty pageBaseTypeProp
;
58 static ConfigurationProperty pageParserFilterTypeProp
;
59 static ConfigurationProperty smartNavigationProp
;
60 static ConfigurationProperty styleSheetThemeProp
;
61 static ConfigurationProperty tagMappingProp
;
62 static ConfigurationProperty themeProp
;
63 static ConfigurationProperty userControlBaseTypeProp
;
64 static ConfigurationProperty validateRequestProp
;
65 static ConfigurationProperty viewStateEncryptionModeProp
;
67 static PagesSection ()
69 asyncTimeoutProp
= new ConfigurationProperty ("asyncTimeout", typeof (TimeSpan
), TimeSpan
.FromSeconds (45.0),
70 PropertyHelper
.TimeSpanSecondsConverter
,
71 PropertyHelper
.PositiveTimeSpanValidator
,
72 ConfigurationPropertyOptions
.None
);
73 autoEventWireupProp
= new ConfigurationProperty ("autoEventWireup", typeof(bool), true);
74 bufferProp
= new ConfigurationProperty ("buffer", typeof(bool), true);
75 controlsProp
= new ConfigurationProperty ("controls", typeof(TagPrefixCollection
), null,
76 null, null, ConfigurationPropertyOptions
.None
);
77 enableEventValidationProp
= new ConfigurationProperty ("enableEventValidation", typeof (bool), true);
78 enableSessionStateProp
= new ConfigurationProperty ("enableSessionState", typeof (string), "true");
79 enableViewStateProp
= new ConfigurationProperty ("enableViewState", typeof (bool), true);
80 enableViewStateMacProp
= new ConfigurationProperty ("enableViewStateMac", typeof (bool), true);
81 maintainScrollPositionOnPostBackProp
= new ConfigurationProperty ("maintainScrollPositionOnPostBack", typeof (bool), false);
82 masterPageFileProp
= new ConfigurationProperty ("masterPageFile", typeof (string), "");
83 maxPageStateFieldLengthProp
= new ConfigurationProperty ("maxPageStateFieldLength", typeof (int), -1);
84 modeProp
= new ConfigurationProperty ("compilationMode", typeof (CompilationMode
), CompilationMode
.Always
,
85 new GenericEnumConverter (typeof (CompilationMode
)), PropertyHelper
.DefaultValidator
,
86 ConfigurationPropertyOptions
.None
);
87 namespacesProp
= new ConfigurationProperty ("namespaces", typeof (NamespaceCollection
), null,
88 null, null, ConfigurationPropertyOptions
.None
);
89 pageBaseTypeProp
= new ConfigurationProperty ("pageBaseType", typeof (string), "System.Web.UI.Page");
90 pageParserFilterTypeProp
= new ConfigurationProperty ("pageParserFilterType", typeof (string), "");
91 smartNavigationProp
= new ConfigurationProperty ("smartNavigation", typeof (bool), false);
92 styleSheetThemeProp
= new ConfigurationProperty ("styleSheetTheme", typeof (string), "");
93 tagMappingProp
= new ConfigurationProperty ("tagMapping", typeof (TagMapCollection
), null,
94 null, null, ConfigurationPropertyOptions
.None
);
95 themeProp
= new ConfigurationProperty ("theme", typeof (string), "");
96 userControlBaseTypeProp
= new ConfigurationProperty ("userControlBaseType", typeof (string), "System.Web.UI.UserControl");
97 validateRequestProp
= new ConfigurationProperty ("validateRequest", typeof (bool), true);
98 viewStateEncryptionModeProp
= new ConfigurationProperty ("viewStateEncryptionMode", typeof (ViewStateEncryptionMode
), ViewStateEncryptionMode
.Auto
,
99 new GenericEnumConverter (typeof (ViewStateEncryptionMode
)), PropertyHelper
.DefaultValidator
,
100 ConfigurationPropertyOptions
.None
);
102 properties
= new ConfigurationPropertyCollection ();
103 properties
.Add (asyncTimeoutProp
);
104 properties
.Add (autoEventWireupProp
);
105 properties
.Add (bufferProp
);
106 properties
.Add (controlsProp
);
107 properties
.Add (enableEventValidationProp
);
108 properties
.Add (enableSessionStateProp
);
109 properties
.Add (enableViewStateProp
);
110 properties
.Add (enableViewStateMacProp
);
111 properties
.Add (maintainScrollPositionOnPostBackProp
);
112 properties
.Add (masterPageFileProp
);
113 properties
.Add (maxPageStateFieldLengthProp
);
114 properties
.Add (modeProp
);
115 properties
.Add (namespacesProp
);
116 properties
.Add (pageBaseTypeProp
);
117 properties
.Add (pageParserFilterTypeProp
);
118 properties
.Add (smartNavigationProp
);
119 properties
.Add (styleSheetThemeProp
);
120 properties
.Add (tagMappingProp
);
121 properties
.Add (themeProp
);
122 properties
.Add (userControlBaseTypeProp
);
123 properties
.Add (validateRequestProp
);
124 properties
.Add (viewStateEncryptionModeProp
);
127 public PagesSection ()
131 [TimeSpanValidator (MinValueString
= "00:00:00",
132 MaxValueString
= "10675199.02:48:05.4775807")]
133 [TypeConverter (typeof (TimeSpanSecondsConverter
))]
134 [ConfigurationProperty ("asyncTimeout", DefaultValue
= "00:00:45")]
135 public TimeSpan AsyncTimeout
{
136 get { return (TimeSpan) base [asyncTimeoutProp]; }
137 set { base [asyncTimeoutProp] = value; }
140 [ConfigurationProperty ("autoEventWireup", DefaultValue
= true)]
141 public bool AutoEventWireup
{
142 get { return (bool) base [autoEventWireupProp]; }
143 set { base [autoEventWireupProp] = value; }
146 [ConfigurationProperty ("buffer", DefaultValue
= true)]
148 get { return (bool) base [bufferProp]; }
149 set { base [bufferProp] = value; }
152 [ConfigurationProperty ("compilationMode", DefaultValue
= CompilationMode
.Always
)]
153 public CompilationMode CompilationMode
{
154 get { return (CompilationMode) base [modeProp]; }
155 set { base [modeProp] = value; }
158 [ConfigurationProperty ("controls")]
159 public TagPrefixCollection Controls
{
160 get { return (TagPrefixCollection) base[controlsProp]; }
163 [ConfigurationProperty ("enableEventValidation", DefaultValue
= true)]
164 public bool EnableEventValidation
{
165 get { return (bool) base[enableEventValidationProp]; }
166 set { base[enableEventValidationProp] = value; }
169 [ConfigurationProperty ("enableSessionState", DefaultValue
= "true")]
170 public PagesEnableSessionState EnableSessionState
{
172 string enableSessionState
= (string) base [enableSessionStateProp
];
173 switch (enableSessionState
) {
175 return PagesEnableSessionState
.True
;
177 return PagesEnableSessionState
.False
;
179 return PagesEnableSessionState
.ReadOnly
;
181 throw new ConfigurationErrorsException ("The 'enableSessionState'"
182 + " attribute must be one of the following values: true,"
183 + "false, ReadOnly.");
187 case PagesEnableSessionState
.False
:
188 base [enableSessionStateProp
] = "false";
190 case PagesEnableSessionState
.ReadOnly
:
191 base [enableSessionStateProp
] = "ReadOnly";
194 base [enableSessionStateProp
] = "true";
200 [ConfigurationProperty ("enableViewState", DefaultValue
= true)]
201 public bool EnableViewState
{
202 get { return (bool) base[enableViewStateProp]; }
203 set { base[enableViewStateProp] = value; }
206 [ConfigurationProperty ("enableViewStateMac", DefaultValue
= true)]
207 public bool EnableViewStateMac
{
208 get { return (bool) base[enableViewStateMacProp]; }
209 set { base[enableViewStateMacProp] = value; }
212 [ConfigurationProperty ("maintainScrollPositionOnPostBack", DefaultValue
= false)]
213 public bool MaintainScrollPositionOnPostBack
{
214 get { return (bool) base[maintainScrollPositionOnPostBackProp]; }
215 set { base [maintainScrollPositionOnPostBackProp] = value; }
218 [ConfigurationProperty ("masterPageFile", DefaultValue
= "")]
219 public string MasterPageFile
{
220 get { return (string) base[masterPageFileProp]; }
221 set { base[masterPageFileProp] = value; }
224 [ConfigurationProperty ("maxPageStateFieldLength", DefaultValue
= -1)]
225 public int MaxPageStateFieldLength
{
226 get { return (int) base[maxPageStateFieldLengthProp]; }
227 set { base[maxPageStateFieldLengthProp] = value; }
230 [ConfigurationProperty ("namespaces")]
231 public NamespaceCollection Namespaces
{
232 get { return (NamespaceCollection) base[namespacesProp]; }
235 [ConfigurationProperty ("pageBaseType", DefaultValue
= "System.Web.UI.Page")]
236 public string PageBaseType
{
237 get { return (string) base[pageBaseTypeProp]; }
238 set { base[pageBaseTypeProp] = value; }
241 [ConfigurationProperty ("pageParserFilterType", DefaultValue
= "")]
242 public string PageParserFilterType
{
243 get { return (string) base[pageParserFilterTypeProp]; }
244 set { base [pageParserFilterTypeProp] = value; }
247 [ConfigurationProperty ("smartNavigation", DefaultValue
= false)]
248 public bool SmartNavigation
{
249 get { return (bool) base[smartNavigationProp]; }
250 set { base[smartNavigationProp] = value; }
253 [ConfigurationProperty ("styleSheetTheme", DefaultValue
= "")]
254 public string StyleSheetTheme
{
255 get { return (string) base[styleSheetThemeProp]; }
256 set { base[styleSheetThemeProp] = value; }
259 [ConfigurationProperty ("tagMapping")]
260 public TagMapCollection TagMapping
{
261 get { return (TagMapCollection) base [tagMappingProp]; }
264 [ConfigurationProperty ("theme", DefaultValue
= "")]
265 public string Theme
{
266 get { return (string) base[themeProp]; }
267 set { base[themeProp] = value; }
270 [ConfigurationProperty ("userControlBaseType", DefaultValue
= "System.Web.UI.UserControl")]
271 public string UserControlBaseType
{
272 get { return (string) base[userControlBaseTypeProp]; }
273 set { base[userControlBaseTypeProp] = value; }
276 [ConfigurationProperty ("validateRequest", DefaultValue
= true)]
277 public bool ValidateRequest
{
278 get { return (bool) base[validateRequestProp]; }
279 set { base[validateRequestProp] = value; }
282 [ConfigurationProperty ("viewStateEncryptionMode", DefaultValue
= ViewStateEncryptionMode
.Auto
)]
283 public ViewStateEncryptionMode ViewStateEncryptionMode
{
284 get { return (ViewStateEncryptionMode) base [viewStateEncryptionModeProp]; }
285 set { base [viewStateEncryptionModeProp] = value; }
288 protected override ConfigurationPropertyCollection Properties
{
289 get { return properties; }
292 protected override void DeserializeSection (XmlReader reader
)
294 base.DeserializeSection (reader
);
296 /* XXX more here?.. */