2010-04-15 Jb Evain <jbevain@novell.com>
[mcs.git] / class / System.Web.Services / System.Web.Services.Description / ServiceDescriptionBaseCollection.cs
blob6406d36eeb39b65897dc41664256457de8808a6b
1 //
2 // System.Web.Services.Description.ServiceDescriptionBaseCollection.cs
3 //
4 // Author:
5 // Tim Coleman (tim@timcoleman.com)
6 //
7 // Copyright (C) Tim Coleman, 2002
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 using System.Collections;
32 using System.Web.Services;
34 namespace System.Web.Services.Description {
35 public abstract class ServiceDescriptionBaseCollection : CollectionBase {
37 #region Fields
39 Hashtable table = new Hashtable ();
40 object parent;
42 #endregion // Fields
44 #region Constructors
46 internal ServiceDescriptionBaseCollection (object parent)
48 this.parent = parent;
51 #endregion // Constructors
53 #region Properties
55 protected virtual IDictionary Table {
56 get { return table; }
59 #endregion // Properties
61 #region Methods
63 protected virtual string GetKey (object value)
65 return null;
68 protected override void OnClear ()
70 Table.Clear ();
73 protected override void OnInsertComplete (int index, object value)
75 if (GetKey (value) != null)
76 Table [GetKey (value)] = value;
77 SetParent (value, parent);
80 protected override void OnRemove (int index, object value)
82 if (GetKey (value) != null)
83 Table.Remove (GetKey (value));
86 protected override void OnSet (int index, object oldValue, object newValue)
88 if (GetKey (oldValue) != null)
89 Table.Remove (GetKey (oldValue));
90 if (GetKey (newValue) != null)
91 Table [GetKey (newValue)] = newValue;
92 SetParent (newValue, parent);
95 protected virtual void SetParent (object value, object parent)
99 #endregion // Methods