Merge pull request #2080 from upsilon/fix-point-constructor
[mono.git] / mcs / class / System.Web / System.Web.Configuration_2.0 / ProfilePropertySettings.cs
1 //
2 // System.Web.Configuration.ProfilePropertySettingsCollection
3 //
4 // Authors:
5 //      Chris Toshok (toshok@ximian.com)
6 //
7 // (C) 2005 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
32 using System;
33 using System.ComponentModel;
34 using System.Configuration;
35
36 namespace System.Web.Configuration
37 {
38         public sealed class ProfilePropertySettings : ConfigurationElement
39         {
40                 static ConfigurationProperty allowAnonymousProp;
41                 static ConfigurationProperty customProviderDataProp;
42                 static ConfigurationProperty defaultValueProp;
43                 static ConfigurationProperty nameProp;
44                 static ConfigurationProperty providerProp;
45                 static ConfigurationProperty readOnlyProp;
46                 static ConfigurationProperty serializeAsProp;
47                 static ConfigurationProperty typeProp;
48
49                 static ConfigurationPropertyCollection properties;
50
51                 static ProfilePropertySettings ()
52                 {
53                         allowAnonymousProp = new ConfigurationProperty ("allowAnonymous", typeof (bool), false);
54                         customProviderDataProp = new ConfigurationProperty ("customProviderData", typeof (string), "");
55                         defaultValueProp = new ConfigurationProperty ("defaultValue", typeof (string), "");
56                         nameProp = new ConfigurationProperty ("name", typeof (string), null,
57                                                               TypeDescriptor.GetConverter (typeof (string)),
58                                                               new ProfilePropertyNameValidator (),
59                                                               ConfigurationPropertyOptions.IsRequired | ConfigurationPropertyOptions.IsKey);
60                         providerProp = new ConfigurationProperty ("provider", typeof (string), "");
61                         readOnlyProp = new ConfigurationProperty ("readOnly", typeof (bool), false);
62                         serializeAsProp = new ConfigurationProperty ("serializeAs", typeof (SerializationMode), SerializationMode.ProviderSpecific,
63                                                                      new GenericEnumConverter (typeof (SerializationMode)),
64                                                                      PropertyHelper.DefaultValidator,
65                                                                      ConfigurationPropertyOptions.None);
66                         typeProp = new ConfigurationProperty ("type", typeof (string), "string");
67
68                         properties = new ConfigurationPropertyCollection ();
69                         properties.Add (allowAnonymousProp);
70                         properties.Add (customProviderDataProp);
71                         properties.Add (defaultValueProp);
72                         properties.Add (nameProp);
73                         properties.Add (providerProp);
74                         properties.Add (readOnlyProp);
75                         properties.Add (serializeAsProp);
76                         properties.Add (typeProp);
77                 }
78
79                 internal ProfilePropertySettings ()
80                 {
81                 }
82
83                 public ProfilePropertySettings (string name)
84                 {
85                         this.Name = name;
86                 }
87
88                 public ProfilePropertySettings (string name, bool readOnly, SerializationMode serializeAs,
89                                                 string providerName, string defaultValue, string profileType,
90                                                 bool allowAnonymous, string customProviderData)
91                 {
92                         this.Name = name;
93                         this.ReadOnly = readOnly;
94                         this.SerializeAs = serializeAs;
95                         this.Provider = providerName;
96                         this.DefaultValue = defaultValue;
97                         this.Type = profileType;
98                         this.AllowAnonymous = allowAnonymous;
99                         this.CustomProviderData = customProviderData;
100                 }
101
102                 [ConfigurationProperty ("allowAnonymous", DefaultValue = false)]
103                 public bool AllowAnonymous {
104                         get { return (bool) base[allowAnonymousProp]; }
105                         set { base [allowAnonymousProp] = value; }
106                 }
107
108                 [ConfigurationProperty ("customProviderData", DefaultValue = "")]
109                 public string CustomProviderData {
110                         get { return (string) base[customProviderDataProp]; }
111                         set { base[customProviderDataProp] = value; }
112                 }
113                 
114                 [ConfigurationProperty ("defaultValue", DefaultValue = "")]
115                 public string DefaultValue {
116                         get { return (string) base[defaultValueProp]; }
117                         set { base[defaultValueProp] = value; }
118                 }
119                 
120                 [ConfigurationProperty ("name", Options = ConfigurationPropertyOptions.IsRequired | ConfigurationPropertyOptions.IsKey)]
121                 public string Name {
122                         get { return (string) base[nameProp]; }
123                         set { base[nameProp] = value; }
124                 }
125                 
126                 [ConfigurationProperty ("provider", DefaultValue = "")]
127                 public string Provider {
128                         get { return (string) base[providerProp]; }
129                         set { base[providerProp] = value; }
130                 }
131                 
132                 [ConfigurationProperty ("readOnly", DefaultValue = false)]
133                 public bool ReadOnly {
134                         get { return (bool) base[readOnlyProp]; }
135                         set { base[readOnlyProp] = value; }
136                 }
137                 
138                 [ConfigurationProperty ("serializeAs", DefaultValue = "ProviderSpecific")]
139                 public SerializationMode SerializeAs {
140                         get { return (SerializationMode) base[serializeAsProp]; }
141                         set { base[serializeAsProp] = value; }
142                 }
143                 
144                 [ConfigurationProperty ("type", DefaultValue = "string")]
145                 public string Type {
146                         get { return (string) base[typeProp]; }
147                         set { base[typeProp] = value; }
148                 }
149
150                 protected internal override ConfigurationPropertyCollection Properties {
151                         get {
152                                 return properties;
153                         }
154                 }
155                 
156         }
157
158 }
159