2007-05-06 Igor Zelmanovich <igorz@mainsoft.com>
[mono.git] / mcs / class / System.Web / System.Web.Configuration_2.0 / ClientTargetCollection.cs
1 //
2 // System.Web.Configuration.ClientTargetCollection
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 using System;
32 using System.Configuration;
33
34 #if NET_2_0
35
36 namespace System.Web.Configuration {
37
38         [ConfigurationCollection (typeof (ClientTarget), CollectionType = ConfigurationElementCollectionType.AddRemoveClearMap)]
39         public sealed class ClientTargetCollection : ConfigurationElementCollection
40         {
41                 public void Add (ClientTarget clientTarget)
42                 {
43                         BaseAdd (clientTarget);
44                 }
45
46                 public void Clear ()
47                 {
48                         BaseClear ();
49                 }
50
51                 protected override ConfigurationElement CreateNewElement ()
52                 {
53                         return new ClientTarget (null, null);
54                 }
55
56                 protected override object GetElementKey (ConfigurationElement element)
57                 {
58                         return ((ClientTarget)element).Alias;
59                 }
60
61                 public string GetKey (int index)
62                 {
63                         return (string)BaseGetKey (index);
64                 }
65
66                 public void Remove (string name)
67                 {
68                         BaseRemove (name);
69                 }
70
71                 public void Remove (ClientTarget clientTarget)
72                 {
73                         BaseRemove (clientTarget.Alias);
74                 }
75
76                 public void RemoveAt (int index)
77                 {
78                         BaseRemoveAt (index);
79                 }
80
81                 public string[] AllKeys {
82                         get {
83                                 string[] keys = new string[Count];
84                                 for (int i = 0; i < Count; i ++)
85                                         keys[i] = this[i].Alias;
86                                 return keys;
87                         }
88                 }
89
90                 public ClientTarget this [int index] {
91                         get { return (ClientTarget) BaseGet (index); }
92                         set { if (BaseGet (index) != null) BaseRemoveAt (index); BaseAdd (index, value); }
93                 }
94
95                 public new ClientTarget this [string name] {
96                         get { return (ClientTarget) BaseGet (name); }
97                 }
98         }
99 }
100
101 #endif
102