Merge pull request #2080 from upsilon/fix-point-constructor
[mono.git] / mcs / class / System.Web / System.Web.Configuration_2.0 / CustomErrorsSection.cs
1 //
2 // System.Web.Configuration.CustomErrorsSection
3 //
4 // Authors:
5 //      Chris Toshok (toshok@ximian.com)
6 //
7 // (C) 2011 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 using System;
32 using System.Configuration;
33 using System.Xml;
34
35 namespace System.Web.Configuration
36 {
37         public sealed class CustomErrorsSection : ConfigurationSection
38         {
39                 static ConfigurationProperty defaultRedirectProp;
40                 static ConfigurationProperty errorsProp;
41                 static ConfigurationProperty modeProp;
42                 static ConfigurationProperty redirectModeProp;
43                 static ConfigurationPropertyCollection properties;
44
45                 static CustomErrorsSection ()
46                 {
47                         defaultRedirectProp = new ConfigurationProperty ("defaultRedirect", typeof (string), null);
48                         errorsProp = new ConfigurationProperty (String.Empty, typeof (CustomErrorCollection), null,
49                                                                 null, PropertyHelper.DefaultValidator,
50                                                                 ConfigurationPropertyOptions.IsDefaultCollection);
51                         modeProp = new ConfigurationProperty ("mode", typeof (CustomErrorsMode), CustomErrorsMode.RemoteOnly,
52                                                               new GenericEnumConverter (typeof (CustomErrorsMode)),
53                                                               PropertyHelper.DefaultValidator,
54                                                               ConfigurationPropertyOptions.None);
55                         redirectModeProp = new ConfigurationProperty ("redirectMode", typeof (CustomErrorsRedirectMode), CustomErrorsRedirectMode.ResponseRedirect,
56                                                                       new GenericEnumConverter (typeof (CustomErrorsRedirectMode)),
57                                                                       PropertyHelper.DefaultValidator, ConfigurationPropertyOptions.None);
58                         
59                         properties = new ConfigurationPropertyCollection ();
60
61                         properties.Add (defaultRedirectProp);
62                         properties.Add (errorsProp);
63                         properties.Add (modeProp);
64                         properties.Add (redirectModeProp);
65                 }
66
67                 // Why override?
68                 protected internal override void DeserializeSection (XmlReader reader)
69                 {
70                         base.DeserializeSection (reader);
71                 }
72
73                 // Why override?
74                 protected internal override void Reset (ConfigurationElement parentElement)
75                 {
76                         base.Reset (parentElement);
77                 }
78                 
79                 [ConfigurationProperty ("defaultRedirect")]
80                 public string DefaultRedirect {
81                         get { return (string) base [defaultRedirectProp];}
82                         set { base[defaultRedirectProp] = value; }
83                 }
84
85                 [ConfigurationProperty ("", Options = ConfigurationPropertyOptions.IsDefaultCollection)]
86                 public CustomErrorCollection Errors {
87                         get { return (CustomErrorCollection) base [errorsProp];}
88                 }
89
90                 [ConfigurationProperty ("mode", DefaultValue = "RemoteOnly")]
91                 public CustomErrorsMode Mode {
92                         get { return (CustomErrorsMode) base [modeProp];}
93                         set { base[modeProp] = value; }
94                 }
95
96                 [ConfigurationProperty ("redirectMode", DefaultValue = CustomErrorsRedirectMode.ResponseRedirect)]
97                 public CustomErrorsRedirectMode RedirectMode {
98                         get { return (CustomErrorsRedirectMode) base [redirectModeProp]; }
99                         set { base [redirectModeProp] = value; }
100                 }
101
102                 protected internal override ConfigurationPropertyCollection Properties {
103                         get { return properties; }
104                 }
105
106         }
107
108 }
109