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