New test.
[mono.git] / mcs / class / System.Web / System.Web.Configuration_2.0 / ProfileGroupSettingsCollection.cs
1 //
2 // System.Web.Configuration.ProfileGroupSettingsCollection
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.Configuration;
35
36 namespace System.Web.Configuration
37 {
38         [ConfigurationCollection (typeof (ProfileGroupSettings), AddItemName = "group", CollectionType = ConfigurationElementCollectionType.AddRemoveClearMap)]
39         public sealed class ProfileGroupSettingsCollection : ConfigurationElementCollection
40         {
41                 static ConfigurationPropertyCollection properties;
42
43                 static ProfileGroupSettingsCollection ()
44                 {
45                         properties = new ConfigurationPropertyCollection ();
46                 }
47
48                 public ProfileGroupSettingsCollection ()
49                 {
50                 }
51
52                 public void Add (ProfileGroupSettings group)
53                 {
54                         BaseAdd (group);
55                 }
56
57                 public void Clear ()
58                 {
59                         BaseClear ();
60                 }
61
62                 protected override ConfigurationElement CreateNewElement ()
63                 {
64                         return new ProfileGroupSettings ();
65                 }
66
67                 public ProfileGroupSettings Get (int index)
68                 {
69                         return (ProfileGroupSettings) BaseGet (index);
70                 }
71
72                 public ProfileGroupSettings Get (string name)
73                 {
74                         return (ProfileGroupSettings) BaseGet (name);
75                 }
76
77                 protected override object GetElementKey (ConfigurationElement element)
78                 {
79                         return ((ProfileGroupSettings)element).Name;
80                 }
81
82                 public string GetKey (int index)
83                 {
84                         return (string)BaseGetKey (index);
85                 }
86
87                 public int IndexOf (ProfileGroupSettings group)
88                 {
89                         return BaseIndexOf (group);
90                 }
91
92                 [MonoTODO]
93                 protected override bool IsModified ()
94                 {
95                         throw new NotImplementedException ();
96                 }
97
98                 public void Remove (string name)
99                 {
100                         BaseRemove (name);
101                 }
102
103                 public void RemoveAt (int index)
104                 {
105                         BaseRemoveAt (index);
106                 }
107
108                 [MonoTODO]
109                 protected override void ResetModified ()
110                 {
111                         base.ResetModified ();
112                 }
113
114                 public void Set (ProfileGroupSettings group)
115                 {
116                         ProfileGroupSettings existing = Get (group.Name);
117
118                         if (existing == null) {
119                                 Add (group);
120                         }
121                         else {
122                                 int index = BaseIndexOf (existing);
123                                 RemoveAt (index);
124                                 BaseAdd (index, group);
125                         }
126                 }
127
128                 public string[ ] AllKeys {
129                         get {
130                                 string[] keys = new string[Count];
131                                 for (int i = 0; i < Count; i ++)
132                                         keys[i] = this[i].Name;
133                                 return keys;
134                         }
135                 }
136
137                 protected override ConfigurationPropertyCollection Properties {
138                         get { return properties; }
139                 }
140
141                 public ProfileGroupSettings this[int index] {
142                         get { return Get (index); }
143                         set { if (BaseGet (index) != null) BaseRemoveAt (index); BaseAdd (index, value); }
144                 }
145
146                 public new ProfileGroupSettings this[string name] {
147                         get { return (ProfileGroupSettings) BaseGet (name); }
148                 }
149
150         }
151
152 }
153
154 #endif