Backport of some changes from svn trunk - performance improvement and a fix for bug...
[mono-project.git] / mcs / class / System.Web / System.Web.Configuration_2.0 / RootProfilePropertySettingsCollection.cs
blob6e48168d1e3745722870af207f79995f112ec0f6
1 //
2 // System.Web.Configuration.RootProfilePropertySettingsCollection
3 //
4 // Authors:
5 // Chris Toshok (toshok@ximian.com)
6 //
7 // (C) 2005 Novell, Inc (http://www.novell.com)
8 //
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.
31 #if NET_2_0
33 using System;
34 using System.Configuration;
35 using System.Xml;
37 namespace System.Web.Configuration
39 [ConfigurationCollection (typeof (ProfilePropertySettings), CollectionType = ConfigurationElementCollectionType.AddRemoveClearMap)]
40 public sealed class RootProfilePropertySettingsCollection : ProfilePropertySettingsCollection
42 static ConfigurationPropertyCollection properties;
43 ProfileGroupSettingsCollection groupSettings;
45 static RootProfilePropertySettingsCollection ()
47 properties = new ConfigurationPropertyCollection ();
50 public RootProfilePropertySettingsCollection ()
52 groupSettings = new ProfileGroupSettingsCollection ();
55 public override bool Equals (object obj)
57 RootProfilePropertySettingsCollection col = obj as RootProfilePropertySettingsCollection;
58 if (col == null)
59 return false;
61 if (GetType () != col.GetType ())
62 return false;
64 if (Count != col.Count)
65 return false;
67 for (int n = 0; n < Count; n++) {
68 if (!BaseGet (n).Equals (col.BaseGet (n)))
69 return false;
71 return true;
74 public override int GetHashCode ()
76 int code = 0;
77 for (int n = 0; n < Count; n++)
78 code += BaseGet (n).GetHashCode ();
79 return code;
82 protected override bool AllowClear {
83 get { return true; }
86 // LAMESPEC: this is missing from MSDN but is present in 2.0sp1 version of the
87 // class.
88 protected override bool OnDeserializeUnrecognizedElement (string elementName, XmlReader reader)
90 if (elementName == "group") {
91 ProfileGroupSettings newSettings = new ProfileGroupSettings ();
92 newSettings.DoDeserialize (reader);
93 GroupSettings.AddNewSettings (newSettings);
95 return true;
98 return base.OnDeserializeUnrecognizedElement (elementName, reader);
101 // LAMESPEC: this is missing from MSDN, but is present in the 2.0sp1 version of the
102 // class
103 protected override void Unmerge (ConfigurationElement sourceElement, ConfigurationElement parentElement, ConfigurationSaveMode saveMode)
105 // Why override?
106 base.Unmerge (sourceElement, parentElement, saveMode);
109 [ConfigurationProperty ("group")]
110 public ProfileGroupSettingsCollection GroupSettings {
111 get { return groupSettings; }
114 protected override ConfigurationPropertyCollection Properties {
115 get { return properties; }
118 protected override bool ThrowOnDuplicate {
119 get { return true; }
122 // Why override?
123 protected override bool IsModified ()
125 return base.IsModified ();
128 // Why override?
129 protected override void ResetModified ()
131 base.ResetModified ();
134 protected override void Reset (ConfigurationElement parentElement)
136 base.Reset (parentElement);
138 RootProfilePropertySettingsCollection root = (RootProfilePropertySettingsCollection) parentElement;
139 if (root == null)
140 return;
142 GroupSettings.ResetInternal (root.GroupSettings);
147 #endif