2 // System.Web.Configuration.ProfilePropertySettingsCollection
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.
33 using System.ComponentModel;
34 using System.Configuration;
36 namespace System.Web.Configuration
38 public sealed class ProfilePropertySettings : ConfigurationElement
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;
49 static ConfigurationPropertyCollection properties;
51 static ProfilePropertySettings ()
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");
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);
79 internal ProfilePropertySettings ()
83 public ProfilePropertySettings (string name)
88 public ProfilePropertySettings (string name, bool readOnly, SerializationMode serializeAs,
89 string providerName, string defaultValue, string profileType,
90 bool allowAnonymous, string customProviderData)
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;
102 [ConfigurationProperty ("allowAnonymous", DefaultValue = false)]
103 public bool AllowAnonymous {
104 get { return (bool) base[allowAnonymousProp]; }
105 set { base [allowAnonymousProp] = value; }
108 [ConfigurationProperty ("customProviderData", DefaultValue = "")]
109 public string CustomProviderData {
110 get { return (string) base[customProviderDataProp]; }
111 set { base[customProviderDataProp] = value; }
114 [ConfigurationProperty ("defaultValue", DefaultValue = "")]
115 public string DefaultValue {
116 get { return (string) base[defaultValueProp]; }
117 set { base[defaultValueProp] = value; }
120 [ConfigurationProperty ("name", Options = ConfigurationPropertyOptions.IsRequired | ConfigurationPropertyOptions.IsKey)]
122 get { return (string) base[nameProp]; }
123 set { base[nameProp] = value; }
126 [ConfigurationProperty ("provider", DefaultValue = "")]
127 public string Provider {
128 get { return (string) base[providerProp]; }
129 set { base[providerProp] = value; }
132 [ConfigurationProperty ("readOnly", DefaultValue = false)]
133 public bool ReadOnly {
134 get { return (bool) base[readOnlyProp]; }
135 set { base[readOnlyProp] = value; }
138 [ConfigurationProperty ("serializeAs", DefaultValue = "ProviderSpecific")]
139 public SerializationMode SerializeAs {
140 get { return (SerializationMode) base[serializeAsProp]; }
141 set { base[serializeAsProp] = value; }
144 [ConfigurationProperty ("type", DefaultValue = "string")]
146 get { return (string) base[typeProp]; }
147 set { base[typeProp] = value; }
150 protected internal override ConfigurationPropertyCollection Properties {