2 // System.Web.Services.Description.ServiceCollection.cs
\r
5 // Tim Coleman (tim@timcoleman.com)
\r
7 // Copyright (C) Tim Coleman, 2002
\r
10 using System.Web.Services;
\r
12 namespace System.Web.Services.Description {
\r
13 public sealed class ServiceCollection : ServiceDescriptionBaseCollection {
\r
17 ServiceDescription serviceDescription;
\r
19 #endregion // Fields
\r
21 #region Constructors
\r
23 internal ServiceCollection (ServiceDescription serviceDescription)
\r
25 this.serviceDescription = serviceDescription;
\r
28 #endregion // Constructors
\r
32 public Service this [int index] {
\r
34 if (index < 0 || index > Count)
\r
35 throw new ArgumentOutOfRangeException ();
\r
37 return (Service) List[index];
\r
40 set { throw new NotImplementedException (); }
\r
43 public Service this [string name] {
\r
44 get { return this[IndexOf ((Service) Table[name])]; }
\r
47 #endregion // Properties
\r
51 public int Add (Service service)
\r
53 Insert (Count, service);
\r
57 public bool Contains (Service service)
\r
59 return List.Contains (service);
\r
62 public void CopyTo (Service[] array, int index)
\r
64 List.CopyTo (array, index);
\r
67 protected override string GetKey (object value)
\r
69 if (!(value is Service))
\r
70 throw new InvalidCastException ();
\r
72 return ((Service) value).Name;
\r
75 public int IndexOf (Service service)
\r
77 return List.IndexOf (service);
\r
80 public void Insert (int index, Service service)
\r
82 SetParent (service, serviceDescription);
\r
83 Table [GetKey (service)] = service;
\r
84 List.Insert (index, service);
\r
87 public void Remove (Service service)
\r
89 Table.Remove (GetKey (service));
\r
90 List.Remove (service);
\r
93 protected override void SetParent (object value, object parent)
\r
95 ((Service) value).SetParent ((ServiceDescription) parent);
\r
98 #endregion // Methods
\r